LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

How does the lab write index.html without a template file, and what does the page contain?

The copy module with content: instead of src: writes the given text to dest; the text uses facts, so each host's page shows its own FQDN and IP address.

- name: Erstellen der index.html
  ansible.builtin.copy:
    content: >
      {{ ansible_facts['fqdn'] }}
      ({{ ansible_facts['default_ipv4']['address'] }})
      wurde im Modul ITIA erstellt. Aufgabe lhe.
    dest: "{{ web_root }}/index.html"

Three pieces work together:

  • content: makes copy write a string rather than copy a file from the control node. It suits short, generated files; for anything longer, a Jinja2 template with ansible.builtin.template is clearer.
  • > (YAML folded block) joins the three lines with spaces, so the file contains one line.
  • Facts fill in the host-specific parts: fqdn is the host's fully qualified name, default_ipv4['address'] the address of its default interface.

The page reads, for example, web1.example.com (192.0.2.15) wurde im Modul ITIA erstellt. Aufgabe lhe. ("was created in module ITIA, task lhe"). Because the content is computed, the curl check at the end proves both that HTTPS works and that the page came from this run on this host.

Go deeper:

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