1
1
ansible_vagrant/playbook/install-zabbix-agent.yml

67 lines
2.0 KiB
YAML
Raw Normal View History

2023-06-29 21:28:49 +02:00
---
- hosts: all
become: true
tasks:
- name: Zabbix Agent telepítése [Red Hat family]
yum:
name: zabbix-agent
state: latest
update_cache: yes
when:
- ansible_os_family == "RedHat"
- name: Zabbix Agent telepítése [Debian family]
apt:
name: zabbix-agent
state: latest
update_cache: yes
when:
- ansible_os_family == "Debian"
2023-06-30 21:25:21 +02:00
- name: Zabbix Agent konfigurálása [Red Hat family]
2023-06-29 21:28:49 +02:00
lineinfile:
path: '/etc/zabbix_agentd.conf'
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
backup: yes
with_items:
- {regexp: '^\s*#?\s*Server\s*=', line: 'Server={{ ZBXSERVER }}'}
- {regexp: '^\s*#?\s*Hostname\s*=', line: 'Hostname={{ inventory_hostname_short }}'}
- {regexp: '^\s*#?\s*LogFileSize\s*=', line: 'LogFileSize={{ ZBXLOGFILESIZE }}'}
- {regexp: '^\s*#?\s*ListenPort\s*=', line: 'ListenPort={{ ZBXAGENTPORT }}'}
- {regexp: '^\s*#?\s*ListenIP\s*=', line: 'ListenIP={{ ZBXLISTENIP }}'}
notify:
- restart zabbix-agent
when:
2023-06-30 21:25:21 +02:00
- ansible_os_family == "RedHat"
2023-06-29 21:28:49 +02:00
- name: Zabbix Agent konfigurálása [Debian family]
lineinfile:
path: '/etc/zabbix/zabbix_agentd.conf'
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
backup: yes
with_items:
- {regexp: '^\s*#?\s*Server\s*=', line: 'Server={{ ZBXSERVER }}'}
- {regexp: '^\s*#?\s*Hostname\s*=', line: 'Hostname={{ inventory_hostname_short }}'}
- {regexp: '^\s*#?\s*LogFileSize\s*=', line: 'LogFileSize={{ ZBXLOGFILESIZE }}'}
- {regexp: '^\s*#?\s*ListenPort\s*=', line: 'ListenPort={{ ZBXAGENTPORT }}'}
- {regexp: '^\s*#?\s*ListenIP\s*=', line: 'ListenIP={{ ZBXLISTENIP }}'}
notify:
- restart zabbix-agent
when:
- ansible_os_family == "Debian"
- name: Zabbix Agent engedélyezése és elindítása
service:
name: zabbix-agent
enabled: yes
state: started
handlers:
- name: restart zabbix-agent
service: name=zabbix-agent state=restarted