# roles/apache/tasks/main.yml
---
- name: Install Apache (Ubuntu/Debian)
  apt:
    name: "{{ apache_package_name }}"
    state: present
  when: ansible_os_family == "Debian"

- name: Configure Apache DocumentRoot (Ubuntu/Debian)
  template:
    src: apache.conf.j2
    dest: "/etc/apache2/sites-available/000-default.conf"
  when: ansible_os_family == "Debian"
  notify:
    - restart apache

- name: Enable and start Apache service
  service:
    name: "{{ apache_service_name }}"
    state: started
    enabled: yes
  when: ansible_os_family == "Debian"


- name: Enable rewrite module
  community.general.apache2_module:
    name: rewrite
    state: present
    ignore_configcheck: True
