mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-01-23 20:39:26 +00:00
bitwarden
This commit is contained in:
parent
36ba99e07c
commit
a8ceb73219
@ -1,22 +1,23 @@
|
||||
- hosts: datacenter
|
||||
name: Install zabbix agent
|
||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||
vars:
|
||||
ZABBIX_SERVER: "zabbix.home.lan"
|
||||
tasks:
|
||||
|
||||
- name: Combine list1 and list2 into a merged_list var
|
||||
- name: Get config for not nas
|
||||
ansible.builtin.set_fact:
|
||||
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:
|
||||
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
|
||||
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
|
||||
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
|
||||
when:
|
||||
- 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
|
||||
ansible.builtin.apt:
|
||||
@ -42,7 +42,6 @@
|
||||
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
|
||||
|
||||
ignore_errors: true
|
||||
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
|
||||
|
||||
- name: Install a .deb package from the internet3
|
||||
ansible.builtin.apt:
|
||||
@ -50,7 +49,6 @@
|
||||
|
||||
when:
|
||||
- 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
|
||||
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
|
||||
when:
|
||||
- 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
|
||||
# ansible.builtin.apt:
|
||||
@ -71,9 +68,7 @@
|
||||
- zabbix-agent2-plugin-postgresql
|
||||
- zabbix-agent2-plugin-mssql
|
||||
update_cache: yes
|
||||
when: inventory_hostname not in groups['nas.home.lan']
|
||||
become: "{{ false if inventory_hostname in groups['nas.home.lan'] else true }}"
|
||||
|
||||
when: inventory_hostname != 'nas.home.lan'
|
||||
|
||||
- name: Reconfigure zabbix agent Server
|
||||
ansible.builtin.lineinfile:
|
||||
@ -81,14 +76,13 @@
|
||||
regexp: "^Server=.*"
|
||||
insertafter: '^# Server='
|
||||
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
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ zabbix_agent_cfg }}"
|
||||
regexp: "^ServerActive=.*"
|
||||
line: "ServerActive={{ ZABBIX_SERVER }}"
|
||||
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
|
||||
|
||||
- name: Reconfigure zabbix agent ListenPort
|
||||
ansible.builtin.lineinfile:
|
||||
@ -100,41 +94,26 @@
|
||||
# path: /"{{ zabbix_agent_cfg }}"
|
||||
# regexp: "^ListenIP=.*"
|
||||
# line: "ListenIP=0.0.0.0"
|
||||
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
|
||||
|
||||
- name: Reconfigure zabbix-agent2 hostname
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ zabbix_agent_cfg }}"
|
||||
regexp: "^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
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ zabbix_agent_cfg }}"
|
||||
insertafter: '^# UserParameter='
|
||||
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 in groups['nas.home.lan']
|
||||
when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
|
||||
|
||||
- name: Reconfigure zabbix-agent2 config
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ zabbix_agent_cfg }}"
|
||||
insertafter: '^# UserParameter='
|
||||
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 in groups['rpi5.home.lan']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
when: inventory_hostname == 'rpi5.home.lan'
|
||||
|
||||
- name: Reconfigure zabbix-agent2 hostname
|
||||
ansible.builtin.lineinfile:
|
||||
@ -142,24 +121,21 @@
|
||||
regexp: "^HostMetadata=.*"
|
||||
insertafter: '^# HostMetadata='
|
||||
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:
|
||||
name: zabbix
|
||||
groups: video
|
||||
append: yes
|
||||
when: inventory_hostname not in groups['nas.home.lan']
|
||||
become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}"
|
||||
when: inventory_hostname != 'nas.home.lan'
|
||||
|
||||
- name: Restart zabbix-agent2 service
|
||||
ansible.builtin.service:
|
||||
name: zabbix-agent2.service
|
||||
state: restarted
|
||||
enabled: true
|
||||
become: true
|
||||
when: inventory_hostname not in groups['nas.home.lan']
|
||||
when: inventory_hostname != 'nas.home.lan'
|
||||
|
||||
- name: Restart agent
|
||||
ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart
|
||||
when: inventory_hostname in groups['nas.home.lan']
|
||||
when: inventory_hostname == 'nas.home.lan'
|
Loading…
x
Reference in New Issue
Block a user