Changed file structure. Added zabbix proxy playbook

This commit is contained in:
2025-08-24 14:30:55 +02:00
parent 0a3b5a9e2c
commit 004264bb38
4 changed files with 96 additions and 28 deletions

View File

@@ -1,14 +1,14 @@
- name: Upgrade packages
hosts: ubuntu
become: true
tasks:
- name: Update cache
ansible.builtin.apt:
update_cache: true
register: cache_updated
- name: Upgrade packages if something is changed
ansible.builtin.apt:
upgrade: "yes"
- name: Upgrade packages
hosts: ubuntu
become: true
tasks:
- name: Update cache
ansible.builtin.apt:
update_cache: true
register: cache_updated
- name: Upgrade packages if something is changed
ansible.builtin.apt:
upgrade: "yes"
when: cache_updated.changed

View File

@@ -1,16 +1,16 @@
- name: Upgrade zabbix agent
hosts: zagents
become: true
tasks:
- name: Ensure that Zabbix agent is at the latest version
ansible.builtin.apt:
name: zabbix-agent2
state: latest
register: zabbix_agent2_status
- name: Upgrade Zabbix agent if not latest
ansible.builtin.apt:
name: zabbix-agent2
upgrade: yes
- name: Upgrade zabbix agent
hosts: zagents
become: true
tasks:
- name: Ensure that Zabbix agent is at the latest version
ansible.builtin.apt:
name: zabbix-agent2
state: latest
register: zabbix_agent2_status
- name: Upgrade Zabbix agent if not latest
ansible.builtin.apt:
name: zabbix-agent2
upgrade: yes
when: zabbix_agent2_status.changed

View File

@@ -0,0 +1,68 @@
---
- name: Install and Configure Zabbix Proxy
hosts: zabbix-proxy # Assuming you have a group for zabbix proxy in your inventory
become: yes
vars_files:
- ../secrets.yml
tasks:
- name: Add Zabbix repository
ansible.builtin.apt_repository:
repo: "deb https://repo.zabbix.com/zabbix/7.4/ubuntu {{ ansible_distribution_release }} main"
state: present
filename: zabbix
- name: Install Zabbix proxy
ansible.builtin.apt:
name: zabbix-proxy-sqlite3
state: present
update_cache: yes
- name: Create Zabbix proxy configuration file
ansible.builtin.copy:
dest: /etc/zabbix/zabbix_proxy.conf.d/mbuz.conf
content: |
Server={{ zabbix_server_address }}:10051
Hostname={{ zabbix_proxy_hostname }}
DBName=/tmp/zabbix_proxy
StartPollers=2
StartPreprocessors=1
StartTrappers=1
StartDiscoverers=1
StartDBSyncers=1
StartAgentPollers=2
EnableRemoteCommands=1
TLSConnect=psk
TLSAccept=psk
TLSPSKFile=/etc/zabbix/lxc-proxy.psk
TLSPSKIdentity={{ zabbix_psk_identity }}
notify: restart zabbix-proxy
- name: Create Zabbix proxy PSK file
ansible.builtin.copy:
dest: /etc/zabbix/proxy.psk
content: "{{ zabbix_proxy_psk }}"
owner: zabbix
group: zabbix
mode: '0600'
notify: restart zabbix-proxy
handlers:
- name: restart zabbix-proxy
ansible.builtin.service:
name: zabbix-proxy
state: restarted
enabled: yes
- name: Verify Zabbix Proxy Service
hosts: zabbix_proxy
become: yes
tasks:
- name: Check if Zabbix proxy service is running
ansible.builtin.service_facts:
- name: Assert that Zabbix proxy is running
ansible.builtin.assert:
that:
- "ansible_facts.services['zabbix-proxy.service'].state == 'running'"
fail_msg: "Zabbix proxy is not running"
success_msg: "Zabbix proxy is running"