Quiz Entry - updated: 2026.10.30
What does a minimal playbook that installs Apache, deploys an index.html and starts the service look like on Debian, and what does each task do?
One play against the Debian hosts with become: true, and three tasks: package makes sure apache2 is installed, copy puts files/index.html into /var/www/html/, and service makes sure apache2 is started and enabled at boot.
- name: Install and start Apache HTTPD
hosts: debian
become: true
tasks:
- name: Install httpd
ansible.builtin.package:
name: apache2
state: present
- name: Ensure index.html is in place
ansible.builtin.copy:
src: files/index.html
dest: /var/www/html/index.html
- name: Start service httpd, if not started
ansible.builtin.service:
name: apache2
state: started
enabled: true
become: true: installing packages and writing to/var/wwwneed root.package: the generic package module; on Debian it uses apt underneath. The package is calledapache2on Debian (httpdon RHEL).copy:srcis on the control node, relative to the playbook directory, so the lab createsplaybook-basic/files/index.htmlnext tosite.yml.destis on the managed host. It only copies if the content differs.service:state: startedstarts Apache if it isn't running;enabled: truemakes it start on boot.
Afterwards, curl localhost on the server returns the test page.
Go deeper:
copy module (official docs) —
srclookup paths,content,mode,backup.service module (official docs) —
started/stopped/restarted/reloadedandenabled.