From 9f549c4076554431c9b0f2ce90517d3a00426c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rkus=20S=C3=A1ndor?= Date: Sat, 1 Jul 2023 12:49:46 +0200 Subject: [PATCH] v 6.0 --- inventory/inventory.yml | 14 ++++++++ playbook/install-zabbix-agent.yml | 60 ++----------------------------- 2 files changed, 17 insertions(+), 57 deletions(-) diff --git a/inventory/inventory.yml b/inventory/inventory.yml index 5b59a09..8b02597 100644 --- a/inventory/inventory.yml +++ b/inventory/inventory.yml @@ -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: diff --git a/playbook/install-zabbix-agent.yml b/playbook/install-zabbix-agent.yml index 1caa282..9eb8ee4 100644 --- a/playbook/install-zabbix-agent.yml +++ b/playbook/install-zabbix-agent.yml @@ -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