LOGBOOK

HELP

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/www need root.
  • package: the generic package module; on Debian it uses apt underneath. The package is called apache2 on Debian (httpd on RHEL).
  • copy: src is on the control node, relative to the playbook directory, so the lab creates playbook-basic/files/index.html next to site.yml. dest is on the managed host. It only copies if the content differs.
  • service: state: started starts Apache if it isn't running; enabled: true makes it start on boot.

Afterwards, curl localhost on the server returns the test page.

Go deeper:

From Quiz: ITIA / Ansible Inventory, Configuration and Playbooks | Updated: Oct 30, 2026