Ansible project generation tool
Project description
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
---False
verbose
---False
inventories
---['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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for ansible_generator-3.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ba112f2c48b2df290359c12dc4aadb09f9818e3ed1397dbf01d2518c43cc961 |
|
MD5 | 7473c5c16a537f35ff4ee932b52f157d |
|
BLAKE2b-256 | 5ed63b1a8070123b69e62b6ca77e34e7a290ee031fa9949c6407dfbd2a08fc99 |