1
1
ansible_vagrant/playbook/install-zabbix-agent.yml
2023-06-29 21:28:49 +02:00

67 lines
2.0 KiB
YAML

---
- 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"
- name: Zabbix Agent konfigurálása [CentOS]
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:
- ansible_distribution == "CentOS"
- 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