roles/zabbix-agent: Deploy Zabbix agent
The *zabbix-agent* role installs the Zabbix monitoring agent on the managed node, and sets it up to communicate with the Zabbix server specified by the `zabbix_server` variable. This role "should" be compatible with most distributions; it has been tested with Fedora and Gentoo.
This commit is contained in:
47
roles/zabbix-agent/tasks/main.yml
Normal file
47
roles/zabbix-agent/tasks/main.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
- name: load distribution-specifc values
|
||||
include_vars: '{{ item }}'
|
||||
with_first_found:
|
||||
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
|
||||
- '{{ ansible_distribution }}.yml'
|
||||
- '{{ ansible_os_family }}.yml'
|
||||
- defaults.yml
|
||||
|
||||
- name: ensure zabbix agent is installed
|
||||
package:
|
||||
name={{ zbx_agent_required_packages|join('') }}
|
||||
state=present
|
||||
tags:
|
||||
- install
|
||||
|
||||
- name: ensure zabbix agent is configured
|
||||
template:
|
||||
src={{ zbx_agent_config_tmpl }}
|
||||
dest={{ zbx_agent_config }}
|
||||
mode=0644
|
||||
notify: restart zabbix agent
|
||||
- name: ensure zabbix agent config drop-in directory exists
|
||||
file:
|
||||
path={{ zbx_agent_config_dir }}
|
||||
mode=0755
|
||||
seuser=system_u
|
||||
setype=etc_t
|
||||
state=directory
|
||||
- name: ensure zabbix is allowed in the firewall
|
||||
firewalld:
|
||||
port=10050/tcp
|
||||
permanent=no
|
||||
immediate=yes
|
||||
state=enabled
|
||||
tags:
|
||||
- firewalld
|
||||
notify: save firewalld configuration
|
||||
|
||||
- name: ensure zabbix agent starts at boot
|
||||
service:
|
||||
name={{ zbx_agent_svc }}
|
||||
enabled=yes
|
||||
- meta: flush_handlers
|
||||
- name: ensure zabbix agent is running
|
||||
service:
|
||||
name={{ zbx_agent_svc }}
|
||||
state=started
|
||||
Reference in New Issue
Block a user