Lab 6 - Roles¶
Mandatory¶
Your first role¶
Check out the copy module, you will use it in this lab.
Connect to your
srv.<firstname>.labasansibleuserSwitch into your git repo
/home/ansible/trainingcreate a
rolesdirectoryCreate a
ntprole directoryCreate a
ntp/filesdirectoryCopy your
/etc/ntp.confinto this directory ->cp /etc/ntp.conf /home/ansible/training/roles/ntp/files/ntp.confCreate a
ntprole with the following tasks in thetasks/main.yml.- installation via
aptmodule - configuration via
copymodule (src: ntp.conf) - notify a handler after a config change
- installation via
Playbook with a role¶
- Create a new playbook named
ntp-role.yml - Link
web1.<firstname>.labwith the new role - Run the playbook
Add Tags to the ntp role¶
- Tag the configuration task with
configuration - Tag the installation task with
installation
Test the handler¶
- change the ntp config
files/ntp.conf - Run the playbook again -> service should be restarted
Create a python-pip role¶
- Create a new
python-piprole - use the
packagemodule for the installation of the packagepython-pip - extend the role list with the
python-piprole in the already existingntp-role.ymlplaybook
Run playbook with tag¶
Run only the tag installation
Commit your changes¶
- add all files to your git repo and commit it