ansible-role-zabbix-agent/tasks/main.yml

43 lines
1.4 KiB
YAML

---
- name: Check if the zabbix repository is installed
package_facts:
manager: "auto"
when:
- zabbix_agent_install | bool
tags: [ 'zabbix', 'zabbix_agent' ]
- import_tasks: zabbix-agent-deb.yml
when:
- zabbix_agent_install | bool
- ansible_distribution_file_variety == "Debian"
- import_tasks: zabbix-agent-rh.yml
when:
- ansible_distribution_file_variety == "RedHat"
- zabbix_agent_install | bool
- import_tasks: zabbix-agent_firewalld_rules.yml
when:
- ansible_distribution_file_variety == "RedHat"
- zabbix_agent_install | bool
- name: Manage the Zabbix agent configuration
block:
- name: Install the zabbix agent configuration file
template: src=zabbix_agentd.conf.j2 dest={{ zabbix_agent_conf_dir }}/zabbix_agentd.conf owner=root group=zabbix mode=0440
notify: restart zabbix-agent
- name: Install the zabbix PSK file
template: src=zabbix_agentd.psk.j2 dest={{ zabbix_agent_psk_file }} owner=root group=zabbix mode=0440
notify: restart zabbix-agent
when: zabbix_authentication_method == "psk"
when: zabbix_agent_install | bool
tags: [ 'zabbix', 'zabbix_agent', 'zabbix_agent_conf' ]
- name: Manage the Zabbix agent service
block:
- name: Ensure that the zabbix agent service is running and enabled
service: name=zabbix-agent state=started enabled=yes
when: zabbix_agent_install | bool
tags: [ 'zabbix', 'zabbix_agent', 'zabbix_agent_conf' ]