1
1
This commit is contained in:
Márkus Sándor 2023-07-01 12:49:46 +02:00
parent fd12041df7
commit 9f549c4076
2 changed files with 17 additions and 57 deletions

View File

@ -19,3 +19,17 @@ all:
vm4:
ansible_host: 192.168.56.5
ansible_ssh_private_key_file: .vagrant/machines/vm4/virtualbox/private_key
redhat:
vars:
ZBXDIR: '/etc'
ZBXLOGDIR: 'zabbix'
hosts:
vm1:
vm2:
debian:
vars:
ZBXDIR: '/etc/zabbix'
ZBXLOGDIR: 'zabbix-agent'
hosts:
vm3:
vm4:

View File

@ -3,63 +3,9 @@
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 [Red Hat family]
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_os_family == "RedHat"
- 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
- include: ~/git/ansible_vagrant/tasks/install-zabbix_agent.yml
- include: ~/git/ansible_vagrant/tasks/configure-zabbix_agent.yml
- include: ~/git/ansible_vagrant/tasks/service-zabbix_agent.yml
handlers:
- name: restart zabbix-agent