---
- name: Copy the Keepalived Exporter systemd service file
  template:
    src: keepalived_exporter.service.j2
    dest: /etc/systemd/system/keepalived_exporter.service
    owner: root
    group: root
    mode: 0644
  notify: restart keepalived_exporter

- name: Allow Keepalived Exporter port in SELinux on RedHat OS family
  seport:
    ports: "{{ keepalived_exporter_web_listen_address.split(':')[-1] }}"
    proto: tcp
    setype: http_port_t
    state: present
  when:
    - ansible_version.full is version_compare('2.4', '>=')
    - ansible_selinux.status == "enabled"
