bitwarden

This commit is contained in:
jaydee 2024-11-19 14:22:13 +01:00
parent 36ba99e07c
commit a8ceb73219

View File

@ -1,22 +1,23 @@
- hosts: datacenter - hosts: datacenter
name: Install zabbix agent name: Install zabbix agent
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
vars: vars:
ZABBIX_SERVER: "zabbix.home.lan" ZABBIX_SERVER: "zabbix.home.lan"
tasks: tasks:
- name: Combine list1 and list2 into a merged_list var - name: Get config for not nas
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf" zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
when: inventory_hostname not in groups['nas.home.lan'] when: inventory_hostname != 'nas.home.lan'
- name: Combine list1 and list2 into a merged_list var - name: Get config for nas
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_cfg: "/opt/ZabbixAgent/etc/zabbix_agentd.conf" zabbix_agent_cfg: "/opt/ZabbixAgent/etc/zabbix_agentd.conf"
when: inventory_hostname in groups['nas.home.lan'] when: inventory_hostname == 'nas.home.lan'
- name: Print all available facts - name: Print all available facts
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ false if inventory_hostname not in groups['nas.home.lan'] else true }}" msg: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
- name: Print all available facts - name: Print all available facts
ansible.builtin.debug: ansible.builtin.debug:
@ -30,7 +31,6 @@
deb: https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb deb: https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
when: when:
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Ubuntu" - ansible_facts.architecture != "armv7l" and ansible_distribution == "Ubuntu"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Install a .deb package from the internet2 - name: Install a .deb package from the internet2
ansible.builtin.apt: ansible.builtin.apt:
@ -42,7 +42,6 @@
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64" - ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
ignore_errors: true ignore_errors: true
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Install a .deb package from the internet3 - name: Install a .deb package from the internet3
ansible.builtin.apt: ansible.builtin.apt:
@ -50,7 +49,6 @@
when: when:
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11" - ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Install a .deb package from the internet4 - name: Install a .deb package from the internet4
ansible.builtin.apt: ansible.builtin.apt:
@ -58,7 +56,6 @@
deb: https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-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: when:
- ansible_facts.architecture != "armv7l" and ansible_facts.architecture != "aarch64" and ansible_distribution == "Debian" and ansible_distribution_major_version == "12" - ansible_facts.architecture != "armv7l" and ansible_facts.architecture != "aarch64" and ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
# - name: Install a .deb package localy # - name: Install a .deb package localy
# ansible.builtin.apt: # ansible.builtin.apt:
@ -71,9 +68,7 @@
- zabbix-agent2-plugin-postgresql - zabbix-agent2-plugin-postgresql
- zabbix-agent2-plugin-mssql - zabbix-agent2-plugin-mssql
update_cache: yes update_cache: yes
when: inventory_hostname not in groups['nas.home.lan'] when: inventory_hostname != 'nas.home.lan'
become: "{{ false if inventory_hostname in groups['nas.home.lan'] else true }}"
- name: Reconfigure zabbix agent Server - name: Reconfigure zabbix agent Server
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
@ -81,14 +76,13 @@
regexp: "^Server=.*" regexp: "^Server=.*"
insertafter: '^# Server=' insertafter: '^# Server='
line: "Server=192.168.77.0/24" line: "Server=192.168.77.0/24"
become: "{{ false if inventory_hostname in groups['nas.home.lan'] else true }}" become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
- name: Reconfigure zabbix agent ServerActive - name: Reconfigure zabbix agent ServerActive
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ zabbix_agent_cfg }}" path: "{{ zabbix_agent_cfg }}"
regexp: "^ServerActive=.*" regexp: "^ServerActive=.*"
line: "ServerActive={{ ZABBIX_SERVER }}" line: "ServerActive={{ ZABBIX_SERVER }}"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Reconfigure zabbix agent ListenPort - name: Reconfigure zabbix agent ListenPort
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
@ -100,41 +94,26 @@
# path: /"{{ zabbix_agent_cfg }}" # path: /"{{ zabbix_agent_cfg }}"
# regexp: "^ListenIP=.*" # regexp: "^ListenIP=.*"
# line: "ListenIP=0.0.0.0" # line: "ListenIP=0.0.0.0"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Reconfigure zabbix-agent2 hostname - name: Reconfigure zabbix-agent2 hostname
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ zabbix_agent_cfg }}" path: "{{ zabbix_agent_cfg }}"
regexp: "^Hostname=.*" regexp: "^Hostname=.*"
line: "Hostname={{ansible_hostname}}" line: "Hostname={{ansible_hostname}}"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Reconfigure zabbix-agent2 hostname
ansible.builtin.lineinfile:
path: "{{ zabbix_agent_cfg }}"
insertafter: '^# UserParameter='
line: "UserParameter=system.temperature,vcgencmd measure_temp"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Reconfigure zabbix-agent2 config - name: Reconfigure zabbix-agent2 config
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ zabbix_agent_cfg }}" path: "{{ zabbix_agent_cfg }}"
insertafter: '^# UserParameter=' insertafter: '^# UserParameter='
line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py" line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}" when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
when: inventory_hostname in groups['nas.home.lan']
- name: Reconfigure zabbix-agent2 config - name: Reconfigure zabbix-agent2 config
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ zabbix_agent_cfg }}" path: "{{ zabbix_agent_cfg }}"
insertafter: '^# UserParameter=' insertafter: '^# UserParameter='
line: "UserParameter=rpi.hw.temp,/usr/bin/vcgencmd measure_temp" line: "UserParameter=rpi.hw.temp,/usr/bin/vcgencmd measure_temp"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}" when: inventory_hostname == 'rpi5.home.lan'
when: inventory_hostname in groups['rpi5.home.lan']
- name: Reconfigure zabbix-agent2 hostname - name: Reconfigure zabbix-agent2 hostname
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
@ -142,24 +121,21 @@
regexp: "^HostMetadata=.*" regexp: "^HostMetadata=.*"
insertafter: '^# HostMetadata=' insertafter: '^# HostMetadata='
line: "HostMetadata=linux;jaydee" line: "HostMetadata=linux;jaydee"
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Add the user 'james' with a bash shell, appending the group 'admins' and 'developers' to the user's groups - name: Add the user 'to group video
ansible.builtin.user: ansible.builtin.user:
name: zabbix name: zabbix
groups: video groups: video
append: yes append: yes
when: inventory_hostname not in groups['nas.home.lan'] when: inventory_hostname != 'nas.home.lan'
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
- name: Restart zabbix-agent2 service - name: Restart zabbix-agent2 service
ansible.builtin.service: ansible.builtin.service:
name: zabbix-agent2.service name: zabbix-agent2.service
state: restarted state: restarted
enabled: true enabled: true
become: true when: inventory_hostname != 'nas.home.lan'
when: inventory_hostname not in groups['nas.home.lan']
- name: Restart agent - name: Restart agent
ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart
when: inventory_hostname in groups['nas.home.lan'] when: inventory_hostname == 'nas.home.lan'