---
# file: roles/haproxy/tasks/zabbix.yml

- name: "apt install socat"
  apt:
    name:
      - socat
      - rsync

- name: "[zabbix] cache scripts"
  copy:
    src: "{{ item }}"
    dest: "/etc/zabbix/scripts/{{ item }}"
    mode: 0755
  loop:
    - haproxy_discovery.sh
    - haproxy_info.sh
    - haproxy_stat.py

- name: "[zabbix] userparameters"
  copy:
    src: haproxy.conf
    dest: /etc/zabbix/zabbix_agentd.conf.d/haproxy.conf
    mode: 0644
  notify: restart zabbix_agent

- name: "[zabbix] https discovery file /usr/local/etc/tls/zabbix.discovery"
  template:
    src: zabbix.discovery
    dest: /usr/local/etc/tls/zabbix.discovery
  when: haproxy_https_monitoring is defined
