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:makescopywrite a string rather than copy a file from the control node. It suits short, generated files; for anything longer, a Jinja2 template withansible.builtin.templateis clearer.>(YAML folded block) joins the three lines with spaces, so the file contains one line.- Facts fill in the host-specific parts:
fqdnis 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:
ansible.builtin.copy: content (official docs) โ writing a string instead of a file.