mirror of
				https://gitlab.sectorq.eu/jaydee/ansible.git
				synced 2025-10-29 17:40:08 +01:00 
			
		
		
		
	bitwarden
This commit is contained in:
		| @@ -1,22 +1,22 @@ | ||||
| - hosts: datacenter | ||||
|   name: Install zabbix agent | ||||
|   vars: | ||||
|     ZABBIX_SERVER: "zabbix-server.lan" | ||||
|     ZABBIX_SERVER: "zabbix.home.lan" | ||||
|   tasks: | ||||
|  | ||||
|     - name: Combine list1 and list2 into a merged_list var | ||||
|       ansible.builtin.set_fact: | ||||
|         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 | ||||
|       ansible.builtin.set_fact: | ||||
|         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 | ||||
|       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 | ||||
|       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 | ||||
|       when: | ||||
|         - 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 | ||||
|       ansible.builtin.apt: | ||||
| @@ -42,7 +42,7 @@ | ||||
|         - ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64" | ||||
|  | ||||
|       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 | ||||
|       ansible.builtin.apt: | ||||
| @@ -50,7 +50,7 @@ | ||||
|          | ||||
|       when: | ||||
|         - 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 | ||||
|       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 | ||||
|       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'] else 'yes' }}" | ||||
|       become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}" | ||||
|  | ||||
|     # - name: Install a .deb package localy | ||||
|     #   ansible.builtin.apt: | ||||
| @@ -71,8 +71,8 @@ | ||||
|           - zabbix-agent2-plugin-postgresql | ||||
|           - zabbix-agent2-plugin-mssql | ||||
|         update_cache: yes | ||||
|       when: inventory_hostname not in groups['nas'] | ||||
|       become: "{{ false if inventory_hostname in groups['nas'] else true }}" | ||||
|       when: inventory_hostname not in groups['nas.home.lan'] | ||||
|       become: "{{ false if inventory_hostname in groups['nas.home.lan'] else true }}" | ||||
|  | ||||
|  | ||||
|     - name: Reconfigure zabbix agent Server | ||||
| @@ -81,14 +81,14 @@ | ||||
|         regexp: "^Server=.*" | ||||
|         insertafter: '^# Server=' | ||||
|         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 | ||||
|       ansible.builtin.lineinfile: | ||||
|         path: "{{ zabbix_agent_cfg }}" | ||||
|         regexp: "^ServerActive=.*" | ||||
|         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 | ||||
|       ansible.builtin.lineinfile: | ||||
| @@ -100,36 +100,36 @@ | ||||
|     #     path: /"{{ zabbix_agent_cfg }}" | ||||
|     #     regexp: "^ListenIP=.*" | ||||
|     #     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 | ||||
|       ansible.builtin.lineinfile: | ||||
|         path: "{{ zabbix_agent_cfg }}" | ||||
|         regexp: "^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 | ||||
|       ansible.builtin.lineinfile: | ||||
|         path: "{{ zabbix_agent_cfg }}" | ||||
|         insertafter: '^# UserParameter=' | ||||
|         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 | ||||
|       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'] else 'yes' }}" | ||||
|       when: inventory_hostname in groups['nas'] | ||||
|       become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}" | ||||
|       when: inventory_hostname in groups['nas.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'] else 'yes' }}" | ||||
|       when: inventory_hostname in groups['raspberrypi5'] | ||||
|       become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}" | ||||
|       when: inventory_hostname in groups['rpi5.home.lan'] | ||||
|  | ||||
|  | ||||
|  | ||||
| @@ -142,15 +142,15 @@ | ||||
|         regexp: "^HostMetadata=.*" | ||||
|         insertafter: '^# HostMetadata=' | ||||
|         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 | ||||
|       ansible.builtin.user: | ||||
|         name: zabbix | ||||
|         groups: video | ||||
|         append: yes | ||||
|       when: inventory_hostname not in groups['nas'] | ||||
|       become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" | ||||
|       when: inventory_hostname not in groups['nas.home.lan'] | ||||
|       become: "{{ 'no' if inventory_hostname in groups['nas.home.lan'] else 'yes' }}" | ||||
|  | ||||
|     - name: Restart zabbix-agent2 service | ||||
|       ansible.builtin.service: | ||||
| @@ -158,8 +158,8 @@ | ||||
|         state: restarted | ||||
|         enabled: true | ||||
|       become: true | ||||
|       when: inventory_hostname not in groups['nas'] | ||||
|       when: inventory_hostname not in groups['nas.home.lan'] | ||||
|  | ||||
|     - name: Restart agent | ||||
|       ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart | ||||
|       when: inventory_hostname in groups['nas'] | ||||
|       when: inventory_hostname in groups['nas.home.lan'] | ||||
		Reference in New Issue
	
	Block a user
	 jaydee
					jaydee