---
- name: Configure the demonstration web server
  hosts: web
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present
        update_cache: true
        cache_valid_time: 3600

    - name: Publish a deterministic home page
      ansible.builtin.copy:
        dest: /var/www/html/index.html
        content: "Infrastructure ready. Configuration managed.\n"
        owner: root
        group: root
        mode: "0644"

    - name: Keep nginx running and enabled
      ansible.builtin.service:
        name: nginx
        state: started
        enabled: true
