A Skeleton for Ansible role development.
Making sure all roles have a consistent template that eases development.
An explanation of conventions used in roles can be found in the docs.
Install from GitHub
git clone https://github.com/kirikae/ansible-skeleton.git
The recommended and portable way to install Ansible is via virtualenv.
# Create a new virtualenv
virtualenv $env_name
# Activate virtualenv
source $env_name/bin/activate
# Install Ansible
pip install ansible
Ansible configuration can be done in multiple
files, depending on your needs by configuring your ansible.cfg
file.
You have to add the following lines to your ansible.cfg
:
[galaxy]
role_skeleton = <path to git repo for ansible-skeleton>/role
skeleton_ignore = ^.git$,^.*/.git_keep$
Molecule must be installed in the same virtualenv (see above).
# Activate virtualenv
source $env_name/bin/activate
# Install molecule and docker support
pip install molecule
To ensure you are developing and testing your role for Ansible Galaxy, some manual steps are required for a fresh role:
# Create Directory from skeleton
ansible-galaxy init $role_name
mv $role_name <github username>.$role_name
Testing is an important part of creating a new role, and good practice for updating existing ones. Details on this can be found in Ansible Tests
MIT
- Kirikae kirikae@cs-network.org