---
- name: "Webserver | Aktiviere Apache-Modul"
  community.general.apache2_module:
    name: "{{ item }}"
    state: present
  notify: restart apache2
  loop:
    - proxy
    - proxy_http

- name: "Webserver | Kopiere Grafana-Seitenkonfiguration"
  ansible.builtin.template:
    src: apache2-site.conf
    dest: "/etc/apache2/sites-available/{{ grafana_domain }}.conf"
    mode: "0644"

- name: "Webserver | Aktiviere Grafana-Seitenkonfiguration"
  ansible.builtin.command:
    cmd: "a2ensite {{ grafana_domain }}"
    creates: "/etc/apache2/site-enabled/{{ grafana_domain }}.conf"
  notify: reload apache2