-
Notifications
You must be signed in to change notification settings - Fork 0
/
zabbix-agents.yml
80 lines (68 loc) · 2.13 KB
/
zabbix-agents.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
- name: Running playbook with a specified command
hosts: "{{ h_group }}"
become: yes
# PROXY IS OPTIONAL
pre_tasks:
- name: Change proxy in /etc/yum.conf
replace:
path: /etc/yum.conf
regexp: '^proxy=.*'
replace: 'proxy=<http/https/sock5...>://<proxy address>:<port>'
tasks:
- name: Check if zabbix-agent has already installed
command: yum list installed zabbix-agent
register: result
ignore_errors: True
- name: If zabbix is not installed
block:
- name: Install RPM
# PROXY IS OPTIONAL
shell: |
all_proxy=<http/https/sock5...>://<proxy address>:<port> rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
ignore_errors: True
- name: Install zabbix-agent
yum:
name: zabbix-agent
state: latest
- name: Copy /etc/zabbix/zabbix_agentd.conf with .j2 {{ ansible_hostname }}
template:
src: ./zabbix_agentd.conf.j2
dest: /etc/zabbix/zabbix_agentd.conf
owner: root
group: root
mode: '0644'
- name: Restart zabbix-agent
systemd:
state: started
enabled: yes
name: zabbix-agent
when: result is failed
- name: If zabbix has been already installed
block:
- name: Copy /etc/zabbix/zabbix_agentd.conf with .j2 {{ ansible_hostname }}
template:
src: ./zabbix_agentd.conf.j2
dest: /etc/zabbix/zabbix_agentd.conf
owner: root
group: root
mode: '0644'
- name: Restart zabbix-agent
systemd:
state: restarted
name: zabbix-agent
when: result is succeeded
- name: Allow 10050 firewall port
firewalld:
port: 10050/tcp
permanent: yes
state: enabled
tags:
- firewall
# PROXY IS OPTIONAL
post_tasks:
- name: Reverting file /etc/yum.conf
replace:
path: /etc/yum.conf
regexp: '^proxy=.*'
replace: 'proxy=http://10.100.150.9:3142'