Automation: Git and Ansible / Stage 5 of 6 · step 5 of 6
An unfinished playbook
Situation
The shop servers need a status page. The status-board application is already installed
(/usr/local/bin/status-board), but nobody wants to set it up by hand on every server. Timur started an Ansible
playbook in ~/status-board and did not get to finish it: ansible-playbook site.yml fails right now.
Task
Finish site.yml so that it brings this machine (localhost from inventory.ini) to the needed state by itself:
- The
statususer is a system user without a login shell (the playbook already has a task for it). - The
/var/lib/statusdata directory: owner and groupstatus, mode0750. - The
/etc/status/status.inisettings come from thetemplates/status.ini.j2template with the variables from the playbook'svars:: owner root, groupstatus, mode0640. - The
lab-statusservice (the unit isfiles/lab-status.service) is running, enabled at boot and answers:curl http://127.0.0.1:8095/. - Running the playbook again changes nothing: the recap says
changed=0.
"Check" runs the playbook by itself. First it removes what the playbook must create: the lab-status service with
its unit, /etc/status, /var/lib/status and the status user. Then it runs ansible-playbook site.yml from
~/status-board twice, as you. So the playbook must do everything — the check removes whatever you set up by hand.
Do not change the application, the files/lab-status.service file or the variables in vars:.
To run it:
cd ~/status-board && ansible-playbook site.yml. Module help —ansible-doc file. There is no internet on the machine.
Lab goals
0 of 5-
ansible-playbook site.yml runs without errors on a machine without the status page — not checked yet
-
The playbook creates the status system user and the /var/lib/status directory (status:status, 0750) — not checked yet
-
/etc/status/status.ini is built from the templates/status.ini.j2 template (root:status, 0640) — not checked yet
-
The lab-status service is running, enabled at boot and answers http://127.0.0.1:8095/ — not checked yet
-
A repeated run changes nothing — changed=0 — not checked yet