LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

Why does the lab end with a task that makes sure /var/www/html/.htaccess does not exist, and how is "does not exist" expressed in Ansible?

The new HTTPS site sets AllowOverride All, so a leftover .htaccess (for example the basic-auth one from an earlier lab) would be honoured and lock the page; ansible.builtin.file with state: absent removes it, and reports ok if it is already gone.

- name: Sicherstellen, dass keine .htaccess-Datei vorhanden ist
  ansible.builtin.file:
    state: absent
    path: "{{ web_root }}/.htaccess"

AllowOverride All in the site's <Directory /var/www/html> section tells Apache to read .htaccess files in that directory and apply their directives. If an earlier exercise left one there with AuthType Basic and Require valid-user, every HTTPS request would get 401 Unauthorized, and the final curl check would fail for a reason that has nothing to do with this playbook.

Declaring the absence is the Ansible way to say "this must not exist". state: absent deletes the file if it is there and does nothing if it isn't, so the task is idempotent, unlike a shell: rm task, which would report changed on every run.

Go deeper:

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