- name: Nginx
  hosts: pi
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present

    - name: Delete default
      ansible.builtin.file:
        path: /etc/nginx/sites-enabled/default
        state: absent

    - name: Copy sites
      ansible.builtin.copy:
        src: sites-enabled/
        dest: /etc/nginx/sites-enabled/
        owner: root
        group: root
        mode: '0644'

    - name: Restart nginx
      ansible.builtin.service:
        name: nginx
        state: restarted
