---

- name: ensure the agent package is installed
  apt:
    name: zabbix-agent
    state: present
  notify:
    - restart zabbix agent
  tags:
    - zabbix

- name: ensure the agent is configured
  template:
    src: zabbix_agentd.conf.j2
    dest: /etc/zabbix/zabbix_agentd.conf
  notify:
    - restart zabbix agent
  tags:
    - zabbix

# TODO
# - name: create directory for external scripts
#   file:
#     path: /usr/local/lib/zabbix/externalscripts
#     state: directory
#     owner: root
#     group: root
#     mode: '0755'
#   tags:
#     - zabbix

- name: ensure the server is enabled and running
  service:
    name: zabbix-agent
    state: started
    enabled: true
  tags:
    - zabbix

- name: ensure zabbix-smart-check is installed
  apt:
    name:
      - zabbix-check-smart
      - zabbix-check-disk-performance
    state: present
  when: "'baremetal' in group_names"
  tags:
    - zabbix
    - hardware-tools
    - chr

- meta: flush_handlers
