1
1

first upload

This commit is contained in:
Márkus Sándor 2023-06-29 21:28:49 +02:00
parent 2a995fd4a8
commit f56c899da5
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,4 @@
ZBXSERVER: '192.168.5.250'
ZBXLOGFILESIZE: '50'
ZBXAGENTPORT: '10050'
ZBXLISTENIP: '0.0.0.0'

View File

@ -0,0 +1,66 @@
---
- 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