---
- name: install promtail
  pacman: name=promtail state=present

- name: install promtail configuration
  template: src=promtail.yaml.j2 dest=/etc/loki/promtail.yaml owner=root group=promtail mode=0640
  notify: restart promtail

- name: open promtail ipv4 port for monitoring.archlinux.org
  ansible.posix.firewalld: zone=wireguard state=enabled permanent=true immediate=yes
    rich_rule="rule family=ipv4 source address={{ hostvars['monitoring.archlinux.org']['wireguard_address'] }} port protocol=tcp port=9080 accept"
  tags:
    - firewall

- name: create drop-in directory for promtail.service
  file: path=/etc/systemd/system/promtail.service.d state=directory owner=root group=root mode=0755

- name: install drop-in for promtail.service
  copy: src=override.conf dest=/etc/systemd/system/promtail.service.d/ owner=root group=root mode=0644
  notify: restart promtail

- name: start and enable promtail
  systemd: name=promtail.service enabled=yes daemon_reload=yes state=started
