Linux Labs

Automation: Git and Ansible / Stage 5 of 6 · step 5 of 6

An unfinished playbook

medium ~25 min
Not running Starting usually ~20 s
Report a problem

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:

  1. The status user is a system user without a login shell (the playbook already has a task for it).
  2. The /var/lib/status data directory: owner and group status, mode 0750.
  3. The /etc/status/status.ini settings come from the templates/status.ini.j2 template with the variables from the playbook's vars:: owner root, group status, mode 0640.
  4. The lab-status service (the unit is files/lab-status.service) is running, enabled at boot and answers: curl http://127.0.0.1:8095/.
  5. 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.

Visible only to you. Saved as you type.

All notes

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

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…