---
# handlers file for zabbix-agent

- name: restart zabbix-agent
  service:
    name: "{{ zabbix_agent_service }}"
    state: restarted
    enabled: yes
  become: yes
  when:
    - not zabbix_agent_docker
    - zabbix_agent_os_family != "Windows" and zabbix_agent_os_family != "Darwin"

- name: firewalld-reload
  command: "firewall-cmd --reload"

- name: restart win zabbix agent
  win_service:
    name: "{{ zabbix_win_agent_service }}"
    state: restarted
  when:
    - zabbix_agent_os_family == "Windows"

- name: restart mac zabbix agent
  command: "launchctl kickstart -k system/{{ zabbix_agent_service }}"
  become: true
  when:
    - not zabbix_agent_docker
    - zabbix_agent_os_family == "Darwin"

- name: "clean repo files from proxy creds"
  shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true
  become: yes
  when:
    - ansible_os_family == 'RedHat'
    - zabbix_http_proxy is defined or zabbix_https_proxy is defined
