Files
Ansible/playbooks/zabbix_proxy_install.yml

78 lines
2.4 KiB
YAML

---
- 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: Download Zabbix release package
ansible.builtin.get_url:
url: "https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu24.04_all.deb"
dest: /tmp/zabbix-release.deb
- name: Install Zabbix release package
ansible.builtin.apt:
deb: /tmp/zabbix-release.deb
- name: Install Zabbix proxy
ansible.builtin.apt:
name: zabbix-proxy-sqlite3
state: present
update_cache: yes
- name: Create Zabbix proxy custom configuration file
ansible.builtin.copy:
dest: /etc/zabbix/zabbix_proxy.d/custom.conf
content: |
DBName=/tmp/zabbix_proxy
StartPollers=2
StartPreprocessors=1
StartTrappers=1
StartDiscoverers=1
StartDBSyncers=1
StartAgentPollers=2
EnableRemoteCommands=1
TLSConnect=psk
TLSAccept=psk
notify: restart zabbix-proxy
- name: Create Zabbix proxy connection configuration file
ansible.builtin.copy:
dest: /etc/zabbix/zabbix_proxy.d/connection.conf
content: |
Server={{ zabbix_server_address }}:10051
Hostname={{ ansible_facts.hostname }}
TLSPSKFile="/etc/zabbix/{{ ansible_facts.hostname }}.psk"
TLSPSKIdentity={{ zabbix_psk_identity }}
notify: restart zabbix-proxy
- name: Create Zabbix proxy PSK file
ansible.builtin.copy:
dest: "/etc/zabbix/{{ ansible_facts.hostname }}.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"