From f56c899da5b9cac555437c04338b29780e6c088d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rkus=20S=C3=A1ndor?= Date: Thu, 29 Jun 2023 21:28:49 +0200 Subject: [PATCH] first upload --- inventory/group_vars/all.yml | 4 ++ playbook/install-zabbix-agent.yml | 66 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 inventory/group_vars/all.yml create mode 100644 playbook/install-zabbix-agent.yml diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml new file mode 100644 index 0000000..81100c4 --- /dev/null +++ b/inventory/group_vars/all.yml @@ -0,0 +1,4 @@ +ZBXSERVER: '192.168.5.250' +ZBXLOGFILESIZE: '50' +ZBXAGENTPORT: '10050' +ZBXLISTENIP: '0.0.0.0' diff --git a/playbook/install-zabbix-agent.yml b/playbook/install-zabbix-agent.yml new file mode 100644 index 0000000..a7b436d --- /dev/null +++ b/playbook/install-zabbix-agent.yml @@ -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