Writing playbooks you need a mechanism for reusability / composeability. You actually got three:
- inclusion
- generalize your playbooks and organize them in roles
- move stuff in modules and have them merged
In [ ]:
cd /notebooks/exercise-09/
You can:
To work on tasklist:
Remember:
The use of the OLD 'include' for tasks has been deprecated. This feature will be removed in a future release.
In [ ]:
# This tasklist requires a variable!
!cat documentroot.yml
In [ ]:
# and here's a play using the include
!cat web-1.yml
In [ ]:
!ansible-playbook -v web-1.yml
In [ ]:
!ansible-playbook web-2.yml
A role is a parametrized playbook that accomplishes a simple task, like:
- install & setup apache (eg. yum + firewall + selinux)
- run checks and send file to support
- implement a set of security policies
- ...
You can get roles from:
/etc/ansible
In [ ]:
cd roles
In [ ]:
!ansible-galaxy init web
Here's a role layout. Main files are:
Being a parameterized playbook, you need to reference parameters and variable, which are defined here:
In [ ]:
!tree .
Inspect the newly created role tree
Let's inspect this mongodb role
In [ ]: