Ansible playbook for playtesting.
You need a valid control node capable of running Ansible and Vagrant. Check control node prerequisites
We create the needed vagrant machines:
export VAGRANT_EXPERIMENTAL="disks"
vagrant up
VAGRANT_EXPERIMENTAL is needed to create a bigger inital disk (80GB instead of 40GB) to complete ex. 2.
Vagrant will provision the vms ensuring python3 is installed, this because centos7 is still defaulting to python2.
Play ansible directly with the inventory parameter.
ansible-playbook playbook.yml -i host.ini
Navigating to http://riker.uss will welcome you with a web page with the iconc USS Enterprise crew.
Using an ansible playbook:
- Provisioning of two CentOS VM, cloud or locally.
- Setting VM: Ensure partition used by Docker is at least 40GB.
- Install Docker on the VMs
- Setting up Docker:
- Securely expose Docker Daemon REST API
- Ensure Docker Daemon is configured as a service that starts on boot.
- Configure a Docker Swarm on the two VMs, securely accessible. Ensure you can deploy services on the swarm.
- Optionally: Test one of the task above using Molecule.
Describe each activity with appropriate Ansible roles and related tasks. The reuse of Ansible roles and playbooks made available in the open-source community is highly recommended (some of which are already linked in the text as an example and below for useful references). In case of code reuse it is important to motivate the role selection criteria, to know its features and contents, and to be able to describe any customizations carried out for the purpose of carrying out the above activities.
Code Versioning:
- Versioning the code on a public repository on Github.com, so that there is a clear description of the work done in the history of the repository;
Continuous Integration:
- Configure a Continuous Integration pipeline on a tool of your choice (tip: Travis, for simple integration with GitHub, Ansible Docker)
- Pipeline should:
- Linting the code and failing in case of errors, which must be suitably corrected.
- Optionally: Execute the test carried out in point 6 automatically at each code push on the repository
References:
- Ansible User Guide: https://docs.ansible.com/ansible/latest/user_guide/index.html
- Ansible Galaxy: https://galaxy.ansible.com/
- Best Practices: http://hakunin.com/six-ansible-practices
- Testing Ansible provisioning locally: https://www.hamvocke.com/blog/local-ansible-testing/
- Testing Ansible roles and playbooks: https://www.digitalocean.com/community/tutorials/how-to-implement-continuous-testing-of-ansible-roles-using-molecule-and-travis-ci-on-ubuntu-18-04
- Version pinning: as general rule, and Docker specific
- Playbook nice example from HPE: https://github.com/HewlettPackard/Docker-SimpliVity