---

- name: Install apache
  become: true
  ansible.builtin.apt:
    name: apache2
    state: present
  notify: Start apache2 service

- name: Remove default html dir
  become: true
  ansible.builtin.file:
    path: /var/www/html
    state: absent

- name: Disable default vHost
  become: true
  ansible.builtin.command:
    cmd: a2dissite 000-default.conf
    removes: /etc/apache2/sites-enabled/000-default.conf
  notify: Reload apache2 service

- name: Remove default vHost conf files
  become: true
  ansible.builtin.file:
    path: "/etc/apache2/sites-available/{{ item }}"
    state: absent
  with_items:
    - 000-default.conf
    - default-ssl.conf

- name: Create /var/www/empty for *:80 vHosts
  become: true
  ansible.builtin.file:
    path: /var/www/empty
    state: directory
    mode: 0755