Linux Labs

Automation: Git and Ansible / Final lab

A site on node2, by a playbook from node1

hard ~50 min
Not running Starting usually ~20 s
Report a problem

Situation

The team's status page is moving to node2. A colleague put together an Ansible project ~/deploy on node1: the site.yml playbook sets up the nginx site status on node2 on port 8080 — the site config and the page from the templates in templates/, with the release taken from the release variable — and reloads nginx with a handler. Before leaving, the colleague ran the playbook: ansible-playbook site.yml finished without errors, yet there is no page on node2. The playbook is going to run every day, so a second run must change nothing.

node1 is your terminal: Ansible runs here, as student, from the ~/deploy directory. student logs in to node2 with a key: ssh node2 'command' or ssh node2, and exit to come back. sudo works without a password on both machines.

Task

  1. ansible-playbook site.yml on node1 configures node2, and the playbook's tasks run on node2.
  2. From node1 curl http://node2:8080/ gets the page from the template — with the release from the release variable.
  3. When the site config on node2 has drifted from the template, a run restores it and nginx reloads the config; a run without changes leaves nginx alone.
  4. A second run succeeds and changes nothing (changed=0), and ansible-playbook site.yml --check --diff finds no differences.

Constraints

  • Fix the ~/deploy project: the playbook configures node2. A manual edit on node2 is brought back to the template by the next run, so the check does not count it.
  • The check runs the playbook itself as student: a normal run (twice if the first one changed something), a run with --check --diff, and then it appends a line to /etc/nginx/sites-available/status on node2 and runs it once more — the playbook has to bring the file back to the template, and nginx has to reload the config.

There is no internet in the lab — only the network between node1 and node2. Everything needed is installed on both machines. After every change run the playbook and look beyond the exit code: at the warnings and the PLAY RECAP.

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 5
  • The site.yml playbook targets node2, and its tasks run on node2 — not checked yet
  • From node1 http://node2:8080/ serves the page from the template, with the release from the release variable — not checked yet
  • When the site config on node2 has drifted from the template, a run restores it and nginx reloads the config; a run without changes leaves nginx alone — not checked yet
  • Running ansible-playbook site.yml again succeeds and changes nothing (changed=0) — not checked yet
  • ansible-playbook site.yml --check --diff finds no differences on node2 — 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…