From 0acc5967de91ac76b1ba2f50e4d5689fff1a2927 Mon Sep 17 00:00:00 2001 From: jaydee Date: Wed, 12 Jun 2024 22:18:47 +0200 Subject: [PATCH] bitwarden --- hosts.yml | 36 ++++++++++++-- playbooks/00_install_zabbix_agent.yml | 72 ++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 16 deletions(-) diff --git a/hosts.yml b/hosts.yml index 69555cf..f01d613 100644 --- a/hosts.yml +++ b/hosts.yml @@ -33,6 +33,16 @@ datacenter: ansible_password: q ansible_become_user: root ansible_become_password: q + ryzen: + hosts: + 192.168.77.15: + vars: + ansible_python_interpreter: auto_silent + ansible_ssh_user: root + ansible_ssh_pass: lacijaydee + ansible_password: lacijaydee + ansible_become_user: root + ansible_become_password: lacijaydee omv: hosts: 192.168.77.189: @@ -105,7 +115,25 @@ datacenter: 192.168.77.106: vars: ansible_ssh_user: admin - ansible_ssh_pass: l4c1!j4yd33?Du5lo - ansible_user: admin - ansible_pass: l4c1!j4yd33?Du5lo - ansible_python_interpreter: /share/ZFS530_DATA/.qpkg/QPython312/bin/python3 \ No newline at end of file + ansible_ssh_pass: l4c1!j4yd33?Du5lo1 + become_method: su + become_user: admin + # ansible_user: admin + # ansible_pass: l4c1!j4yd33?Du5lo1 + ansible_python_interpreter: /share/ZFS530_DATA/.qpkg/QPython312/bin/python3 + fog: + hosts: + 192.168.77.108: + vars: + ansible_ssh_user: jd + ansible_ssh_pass: q + ansible_become_user: root + ansible_become_password: q + zabbix: + hosts: + 192.168.77.216: + vars: + ansible_ssh_user: jd + ansible_ssh_pass: q + ansible_become_user: root + ansible_become_password: q \ No newline at end of file diff --git a/playbooks/00_install_zabbix_agent.yml b/playbooks/00_install_zabbix_agent.yml index 3d1368b..0054418 100644 --- a/playbooks/00_install_zabbix_agent.yml +++ b/playbooks/00_install_zabbix_agent.yml @@ -1,7 +1,23 @@ - hosts: datacenter name: Install zabbix agent - become: true + vars: + ZABBIX_SERVER_IP: "192.168.77.216" 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'] + + - 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'] + + - name: Print all available facts + ansible.builtin.debug: + msg: "{{ false if inventory_hostname not in groups['nas'] else true }}" + - name: Print all available facts ansible.builtin.debug: var: ansible_facts.architecture @@ -14,8 +30,8 @@ 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' }}" - - name: Install a .deb package from the internet 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 @@ -24,15 +40,20 @@ when: - ansible_facts.architecture == "armv7l" ignore_errors: true + become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" - name: Install a .deb package from the internet 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" + become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" + - name: Install a .deb package from the internet 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_distribution == "Debian" and ansible_distribution_major_version == "12" @@ -47,46 +68,73 @@ - zabbix-agent2 - zabbix-agent2-plugin-* update_cache: yes + when: inventory_hostname not in groups['nas'] + + - name: Reconfigure zabbix agent Server ansible.builtin.lineinfile: - path: /etc/zabbix/zabbix_agent2.conf + path: "{{ zabbix_agent_cfg }}" regexp: "^Server=.*" insertafter: '^# Server=' - line: "Server=192.168.77.106" + line: "Server=192.168.77.0/24" + become: "{{ false if inventory_hostname in groups['nas'] else true }}" - name: Reconfigure zabbix agent ServerActive ansible.builtin.lineinfile: - path: /etc/zabbix/zabbix_agent2.conf + path: "{{ zabbix_agent_cfg }}" regexp: "^ServerActive=.*" - line: "ServerActive=192.168.77.106" + line: "ServerActive={{ ZABBIX_SERVER_IP }}" + become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" + - name: Reconfigure zabbix agent ListenPort ansible.builtin.lineinfile: - path: /etc/zabbix/zabbix_agent2.conf + path: "{{ zabbix_agent_cfg }}" regexp: "^ListenPort=.*" line: "ListenPort=10050" # - name: Reconfigure zabbix agent ListenIP # ansible.builtin.lineinfile: - # path: /etc/zabbix/zabbix_agent2.conf + # path: /"{{ zabbix_agent_cfg }}" # regexp: "^ListenIP=.*" # line: "ListenIP=0.0.0.0" - name: Reconfigure zabbix-agent2 hostname ansible.builtin.lineinfile: - path: /etc/zabbix/zabbix_agent2.conf + path: "{{ zabbix_agent_cfg }}" regexp: "^Hostname=.*" line: "Hostname={{ansible_hostname}}" + become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" + - name: Reconfigure zabbix-agent2 hostname ansible.builtin.lineinfile: - path: /etc/zabbix/zabbix_agent2.conf + path: "{{ zabbix_agent_cfg }}" regexp: "^UserParameter=.*" insertafter: '^# UserParameter=' line: "UserParameter=system.temperature,vcgencmd measure_temp" + become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}" + + - name: Reconfigure zabbix-agent2 hostname + ansible.builtin.lineinfile: + path: "{{ zabbix_agent_cfg }}" + regexp: "^HostMetadata=.*" + insertafter: '^# HostMetadata=' + line: "HostMetadata=linux;jaydee" + become: "{{ 'no' if inventory_hostname in groups['nas'] 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'] + + - name: Restart zabbix-agent2 service ansible.builtin.service: name: zabbix-agent2.service state: restarted - enabled: true \ No newline at end of file + enabled: true + become: true + when: inventory_hostname not in groups['nas'] + + - name: Restart agent + ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart + when: inventory_hostname in groups['nas'] \ No newline at end of file