LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

A lab playbook sets up Apache with HTTPS on Debian hosts in one play. Which steps does it run, in which order, and which control-flow tool does each step use?

Fail fast if the host is unsuitable (fail + when), install packages (apt), start services (loop), enable SSL and the HTTPS site (notify), copy certificate and key in a block with rescue, write the page, remove any .htaccess, and restart Apache once at the end (handler).

The lab playbook as a sequence of tasks, each tagged with the tool it uses, ending in the restart handler

* One play, every tool from this topic: when, loop, notify, block/rescue and a handler. *

The play targets the debian group with become: true and loads its settings from a variables file (packages, services, web_service, ssl_cert_dir, ssl_key_dir, web_root, min_ram_mb). In order:

  1. Fast fail check: ansible.builtin.fail with a when on RAM and distribution.
  2. Packages: apt installs apache2, openssl and ca-certificates (state: latest, update_cache: yes).
  3. Services: service with loop: "{{ services }}", started and enabled.
  4. SSL module: shell: a2enmod ssl, notifying Restart web service.
  5. Virtual host: copy the HTTPS site file to /etc/apache2/sites-available/, then shell: a2ensite itia-lhe-ssl.conf, both notifying the handler.
  6. Certificates: a block that creates the two SSL directories and copies certificate and key with a loop over dictionaries; its rescue prints a message.
  7. Content: copy with content: writes index.html from facts.
  8. No auth: file: state: absent removes .htaccess.
  9. Handler: Restart web service restarts apache2, once, after all tasks.

The result is checked with curl -k https://<host>, which should return the generated page.

Go deeper:

From Quiz: ITIA / Ansible Task Control: Loops, Conditionals, Handlers and Error Handling | Updated: Nov 12, 2026