bitwarden

This commit is contained in:
jaydee 2024-11-19 14:07:21 +01:00
parent 1709e6aecf
commit 8d4c82d7d3

View File

@ -1,22 +1,22 @@
- hosts: datacenter - hosts: datacenter
name: Install zabbix agent name: Install zabbix agent
vars: vars:
ZABBIX_SERVER: "zabbix-server.lan" ZABBIX_SERVER: "zabbix.home.lan"
tasks: tasks:
- name: Combine list1 and list2 into a merged_list var - name: Combine list1 and list2 into a merged_list var
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'] when: inventory_hostname not in groups['nas.home.lan']
- name: Combine list1 and list2 into a merged_list var - name: Combine list1 and list2 into a merged_list var
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'] when: inventory_hostname in groups['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'] else true }}" msg: "{{ false if inventory_hostname not in groups['nas.home.lan'] else true }}"
- name: Print all available facts - name: Print all available facts
ansible.builtin.debug: ansible.builtin.debug:
@ -30,7 +30,7 @@
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'] else 'yes' }}" 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,7 @@
- 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'] else 'yes' }}" 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 +50,7 @@
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'] else 'yes' }}" 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 +58,7 @@
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'] else 'yes' }}" 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,8 +71,8 @@
- 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'] when: inventory_hostname not in groups['nas.home.lan']
become: "{{ false if inventory_hostname in groups['nas'] else true }}" become: "{{ false if inventory_hostname in groups['nas.home.lan'] else true }}"
- name: Reconfigure zabbix agent Server - name: Reconfigure zabbix agent Server
@ -81,14 +81,14 @@
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'] else true }}" become: "{{ false if inventory_hostname in groups['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'] else 'yes' }}" 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,36 +100,36 @@
# 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'] else 'yes' }}" 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'] else 'yes' }}" 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 }}"
insertafter: '^# UserParameter=' insertafter: '^# UserParameter='
line: "UserParameter=system.temperature,vcgencmd measure_temp" line: "UserParameter=system.temperature,vcgencmd measure_temp"
become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" 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'] else 'yes' }}" become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
when: inventory_hostname in groups['nas'] 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'] else 'yes' }}" become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
when: inventory_hostname in groups['raspberrypi5'] when: inventory_hostname in groups['rpi5.home.lan']
@ -142,15 +142,15 @@
regexp: "^HostMetadata=.*" regexp: "^HostMetadata=.*"
insertafter: '^# HostMetadata=' insertafter: '^# HostMetadata='
line: "HostMetadata=linux;jaydee" line: "HostMetadata=linux;jaydee"
become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" 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 'james' with a bash shell, appending the group 'admins' and 'developers' to the user's groups
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'] when: inventory_hostname not in groups['nas.home.lan']
become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" 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:
@ -158,8 +158,8 @@
state: restarted state: restarted
enabled: true enabled: true
become: true become: true
when: inventory_hostname not in groups['nas'] 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'] when: inventory_hostname in groups['nas.home.lan']