A Skeleton for developing Ansible Code for while-true-do.io.
Creating a repository is always somewhat interesting and needs a lot explanation. This repository should help to reduce the effort and prepare a ready-to-use environment.
This repository consists of several guidance and skeletons for Ansible:
Install from Github
git clone https://github.com/while-true-do/ansible-skeleton.git
Before creating a new role, please read the below information very carefully. They will explain, how a new role should look like and which steps are needed.
# Create a new virtualenv virtualenv $env_name # Activate virtualenv source $env_name/bin/activate # Install Ansible pip install ansible
On some selinux enabled systems like Fedora, you have to symlink the selinux site-packages manually.
# Search local site-packages find /usr/lib64 -iname "*selinux*" # Now you have to symlink the selinux directory and the python-c-bindings # Example: cd $env_name ln -s /usr/lib64/python3.7/site-packages/_selinux.cpython-37m-x86_64-linux-gnu.so ./lib/python3.7/site-packages/selinux ln -s /usr/lib64/python3.7/site-packages/_selinux.cpython-37m-x86_64-linux-gnu.so ./lib/python3.7/site-packages/_selinux.cpython-37m-x86_64-linux-gnu.so
Furthermore, selinux requires you to allow docker to manage cgroups.
setsebool -P container_manage_cgroup on
Ansible configuration can be done in multiple files, depending on your needs.
# Edit system ansible.cfg sudo vi /etc/ansible/ansible.cfg # Edit user ansible.cfg vi ~/.ansible.cfg # Add one to the specific role vi ansible.cfg (in the current directory)
You have to add the following lines:
[galaxy] role_skeleton = <path_to_ansible-skeleton>/role role_skeleton_ignore = ^.git$,^.*/.git_keep$
# Activate virtualenv source $env_name/bin/activate # Install molecule and docker support pip install molecule[docker]
Some manual steps are needed to create new role from scratch.
# Step 1: Create Directory from skeleton ansible-galaxy init $role_name mv $role_name while_true_do.$role_name # Step 2: Review and Modify all "TODO" steps grep -r "TODO" while_true_do.$role_name
Testing is key for new roles. You want to get comfortable with the Ansible Testing Convention.
This repository is not tested.
Thank you so much for considering to contribute. We are very happy, when somebody is joining the hard work. Please fell free to open Bugs, Feature Requests or Pull Requests after reading the Contribution Guideline.
See who has contributed already in the kudos.txt.
This work is licensed under a BSD-3-Clause License.