This commit is contained in:
2025-04-26 19:37:01 +02:00
parent 5ab8d6cf02
commit f339cb755a

View File

@ -1,4 +1,6 @@
- block:
- name: Install zabbix agent
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
block:
- name: Get config for not nas
ansible.builtin.set_fact:
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
@ -34,30 +36,32 @@
- name: Install a .deb package from the internet2
ansible.builtin.apt:
#deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
# deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
deb: https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian11_all.deb
retries: 5
delay: 5
when:
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
ignore_errors: true
register: command_result
failed_when: "'FAILED' in command_result.stderr"
- name: Install a .deb package from the internet3
ansible.builtin.apt:
deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
when:
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11"
- name: Install a .deb package from the internet4
ansible.builtin.apt:
#deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
# deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
deb: https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian12_all.deb
when:
- ansible_facts.architecture != "armv7l" and ansible_facts.architecture != "aarch64" and ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
ignore_errors: true
- ansible_facts.architecture != "armv7l"
- ansible_facts.architecture != "aarch64"
- ansible_distribution == "Debian"
- ansible_distribution_major_version == "12"
register: command_result
failed_when: "'FAILED' in command_result.stderr"
# - name: Install a .deb package localy
# ansible.builtin.apt:
# deb: /tmp/zabbix-release_6.4-1+ubuntu22.04_all.deb
@ -68,8 +72,7 @@
- zabbix-agent2-plugin-mongodb
- zabbix-agent2-plugin-postgresql
# - zabbix-agent2-plugin-mysql
update_cache: yes
ignore_errors: true
update_cache: true
when: inventory_hostname != 'nas.home.lan'
- name: Reconfigure zabbix agent Server
@ -139,8 +142,6 @@
insertafter: '^# HostMetadata='
line: "HostMetadata=linux;jaydee"
- name: Reconfigure zabbix-agent2 hostname
ansible.builtin.lineinfile:
path: "{{ zabbix_agent_cfg }}"
@ -149,13 +150,11 @@
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
groups: video
append: yes
append: true
when: inventory_hostname != 'nas.home.lan'
@ -168,8 +167,6 @@
- name: Restart agent
ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart
ansible.builtin.command: /etc/init.d/ZabbixAgent.sh restart
when: inventory_hostname == 'nas.home.lan'
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
changed_when: false