From 5259f056650ba2ca83cb61cd07ae042fb10da732 Mon Sep 17 00:00:00 2001 From: jaydee Date: Tue, 17 Dec 2024 00:32:20 +0100 Subject: [PATCH] initial --- roles/docker/handlers/main.yml | 3 ++- roles/zabbix-agent/tasks/main.yml | 29 +++++++++++++++++++++++++---- servers.yml | 6 ++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/roles/docker/handlers/main.yml b/roles/docker/handlers/main.yml index 8fd7f72..90ec872 100755 --- a/roles/docker/handlers/main.yml +++ b/roles/docker/handlers/main.yml @@ -1,4 +1,5 @@ - name: restart_docker ansible.builtin.service: name: docker.service - state: restarted \ No newline at end of file + state: restarted + become: true \ No newline at end of file diff --git a/roles/zabbix-agent/tasks/main.yml b/roles/zabbix-agent/tasks/main.yml index 4f5f161..ec89ea6 100755 --- a/roles/zabbix-agent/tasks/main.yml +++ b/roles/zabbix-agent/tasks/main.yml @@ -77,8 +77,8 @@ path: "{{ zabbix_agent_cfg }}" regexp: "^Server=.*" insertafter: '^# Server=' - line: "Server=192.168.77.0/24,192.168.80.0/28" - become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}" + line: "Server=192.168.77.0/24,172.30.0.0/24" + - name: Reconfigure zabbix agent ServerActive ansible.builtin.lineinfile: @@ -86,6 +86,7 @@ regexp: "^ServerActive=.*" line: "ServerActive={{ ZABBIX_SERVER }}" + - name: Reconfigure zabbix agent ListenPort ansible.builtin.lineinfile: path: "{{ zabbix_agent_cfg }}" @@ -97,19 +98,31 @@ # regexp: "^ListenIP=.*" # line: "ListenIP=0.0.0.0" + - name: Reconfigure zabbix-agent2 hostname ansible.builtin.lineinfile: path: "{{ zabbix_agent_cfg }}" regexp: "^Hostname=.*" line: "Hostname={{ inventory_hostname }}" + - name: Reconfigure zabbix-agent2 config ansible.builtin.lineinfile: path: "{{ zabbix_agent_cfg }}" insertafter: '^# UserParameter=' regexp: "^UserParameter=system.certs.*" line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py" - when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan' + when: inventory_hostname == 'nas.home.lan' + + + - name: Reconfigure zabbix-agent2 config + ansible.builtin.lineinfile: + path: "{{ zabbix_agent_cfg }}" + insertafter: '^# UserParameter=' + regexp: "^UserParameter=system.certs.*" + line: "UserParameter=system.certs,python3 /usr/bin/cert_check2.py" + when: inventory_hostname == 'm-server.home.lan' + - name: Reconfigure zabbix-agent2 config ansible.builtin.lineinfile: @@ -118,12 +131,16 @@ line: "UserParameter=rpi.hw.temp,/usr/bin/vcgencmd measure_temp" when: inventory_hostname == 'rpi5.home.lan' + - name: Reconfigure zabbix-agent2 hostname ansible.builtin.lineinfile: path: "{{ zabbix_agent_cfg }}" regexp: "^HostMetadata=.*" insertafter: '^# HostMetadata=' line: "HostMetadata=linux;jaydee" + + + - name: Reconfigure zabbix-agent2 hostname ansible.builtin.lineinfile: path: "{{ zabbix_agent_cfg }}" @@ -132,6 +149,8 @@ line: "HostMetadata=server;jaydee" when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan' + + - name: Add the user 'to group video ansible.builtin.user: name: zabbix @@ -139,6 +158,7 @@ append: yes when: inventory_hostname != 'nas.home.lan' + - name: Restart zabbix-agent2 service ansible.builtin.service: name: zabbix-agent2.service @@ -146,9 +166,10 @@ enabled: true when: inventory_hostname != 'nas.home.lan' + - name: Restart agent ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart when: inventory_hostname == 'nas.home.lan' - become: true \ No newline at end of file + become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}" \ No newline at end of file diff --git a/servers.yml b/servers.yml index 64fb1f0..1d893b3 100755 --- a/servers.yml +++ b/servers.yml @@ -1,5 +1,5 @@ --- -- hosts: servers +- hosts: containers roles: - name: common tags: common @@ -20,4 +20,6 @@ - name: ldap_client tags: ldap_client - name: ssh_banner - tags: ssh_banner \ No newline at end of file + tags: ssh_banner + - name: omv_backup + tags: omv_backup \ No newline at end of file