Ansible Generator
Description
Ansible Generator is a python program designed to simplify creating a new ansible playbook by creating the necessary directory structure for the user based on ansible's best practices, as outlined in content organization best practices.
Installation
PIP (recommended)
pip install -U ansible-generator
Source
git clone https://github.com/kkirsche/ansible-generator.git
cd ansible-generator
curl -sSL https://install.python-poetry.org | python3 -
poetry build
Usage
Help Text
usage: ansible-generate [-h] [-a] [-i INVENTORIES [INVENTORIES ...]]
[-r ROLES [ROLES ...]] [-v]
[-p PROJECTS [PROJECTS ...]] [--version]
Generate an ansible playbook directory structure
optional arguments:
-h, --help show this help message and exit
-a, --alternate-layout
-i INVENTORIES [INVENTORIES ...], --inventories INVENTORIES [INVENTORIES ...]
-r ROLES [ROLES ...], --roles ROLES [ROLES ...]
-v, --verbose
-p PROJECTS [PROJECTS ...], --projects PROJECTS [PROJECTS ...]
--version show program's version number and exit
Defaults
alternate-layout---Falseverbose---Falseinventories---['production', 'staging']roles---[]projects---[]
Example
Current directory
ansible-generate
New-project
ansible-generate -p playbook_name
Alternate Layout
ansible-generate -a
Custom Inventories
ansible-generate -i production staging lab
Roles
This portion of the tool relies on Ansible's ansible-galaxy command line
application
ansible-generate -r role1 role2
Output
~/Downloads ❯❯❯ ansible-generate -i production staging lab -r common ubuntu centos -a -p network_security_baseline
creating directory /Users/example_user/Downloads/network_security_baseline/roles
creating directory /Users/example_user/Downloads/network_security_baseline/inventories/production/group_vars
creating directory /Users/example_user/Downloads/network_security_baseline/inventories/production/host_vars
creating directory /Users/example_user/Downloads/network_security_baseline/inventories/staging/group_vars
creating directory /Users/example_user/Downloads/network_security_baseline/inventories/staging/host_vars
creating directory /Users/example_user/Downloads/network_security_baseline/inventories/lab/group_vars
creating directory /Users/example_user/Downloads/network_security_baseline/inventories/lab/host_vars
creating file /Users/example_user/Downloads/network_security_baseline/inventories/production/hosts
creating file /Users/example_user/Downloads/network_security_baseline/inventories/staging/hosts
creating file /Users/example_user/Downloads/network_security_baseline/inventories/lab/hosts
creating file /Users/example_user/Downloads/network_security_baseline/site.yml
ansible galaxy output for role common:
- common was created successfully
ansible galaxy output for role ubuntu:
- ubuntu was created successfully
ansible galaxy output for role centos:
- centos was created successfully
Metadata
Release files for ansible-generator 3.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ansible-generator-3.1.1.tar.gz | 9.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ansible_generator-3.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.8 kB
Release files / ansible-generator-3.1.1.tar.gz
| Download URL | ansible-generator-3.1.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fa76e6d7f6c23cf9a900f2366d564767eccffc5cf39b987d00a43195a4cacd7
|
|
BLAKE2b-256 checksum How to use checksums |
ab4dfb94e0b94d7e9fcf0e6c0717fb37c1d700f66eaaeb316f8ca5b5a3360b6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.5 Darwin/21.6.0
|
Release files / ansible_generator-3.1.1-py3-none-any.whl
| Download URL | ansible_generator-3.1.1-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10f6a7cfa00a94850a52f390b2037a82c7072fdbb34cb6e519f15342bb9aa07f
|
|
BLAKE2b-256 checksum How to use checksums |
35a85d3709478a16590704152ff6c18c5ac5625966c23348f54095908d9f1590
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.5 Darwin/21.6.0
|