Step 5 of 6 · lab · 30 min
The role does not apply
The status page playbook was turned into a role so that every shop can use it. On this machine the role fails, and when it passes it shows another shop. Fix the role without touching the values in site.yml.
Situation
Every shop in the chain now needs the status page, and Timur did not want to copy the playbook. He moved the tasks of
the «Юг» (South) shop playbook into the status_board role and left each shop a short site.yml: its own title and
port in vars: and a roles: line. This machine is the «Север» (North) shop, the project is in ~/status-board.
ansible-playbook site.yml fails here.
Task
Fix the roles/status_board role so that site.yml brings this machine (localhost from inventory.ini) to the
needed state by itself:
ansible-playbook site.ymlruns without errors.- The
/etc/status/status.inisettings are built from thestatus.ini.j2role template with the title and port fromsite.yml: owner root, groupstatus, mode0640. - The
lab-statusservice is running, enabled at boot and answers:curl http://127.0.0.1:8096/gives the title «Магазин «Север»: статус витрины». - A run that has changed the settings restarts the service, and a run without changes leaves it alone.
- Running the playbook again changes nothing: the result is
changed=0.
"Check" runs the playbook itself. First it removes what the role does: 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 as you twice, edits the title line in /etc/status/status.ini by hand and runs it a third time —
the service must restart. The last run is --check --diff on a copy of the project where site.yml has a different
title and port: the settings must get them. So the role must do everything — whatever you set up by hand, the check
removes.
Do not change the values in site.yml, the application or the role's lab-status.service unit file.
Run:
cd ~/status-board && ansible-playbook site.yml. What the role holds:find roles -type f. There is no internet on the machine.
Lab · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
Goals
0 of 5-
ansible-playbook site.yml runs without errors on a machine without the status page — not done yet
-
/etc/status/status.ini is built from the role template with the values from site.yml (root:status, 0640) — not done yet
-
The lab-status service is running, enabled at boot and answers http://127.0.0.1:8096/ with the title from site.yml — not done yet
-
The service restarts when a run has changed the settings, and only then — not done yet
-
A repeated run changes nothing — changed=0 — not done yet
The machine is starting
Hints
0 of 3Lab goals
0 of 5-
ansible-playbook site.yml runs without errors on a machine without the status page — not done yet
-
/etc/status/status.ini is built from the role template with the values from site.yml (root:status, 0640) — not done yet
-
The lab-status service is running, enabled at boot and answers http://127.0.0.1:8096/ with the title from site.yml — not done yet
-
The service restarts when a run has changed the settings, and only then — not done yet
-
A repeated run changes nothing — changed=0 — not done yet
Goals are checked on the machine after every command.