Changed file structure. Added zabbix proxy playbook
This commit is contained in:
68
Ansible/playbooks/zabbix_proxy_install.yml
Normal file
68
Ansible/playbooks/zabbix_proxy_install.yml
Normal 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"
|
||||||
Reference in New Issue
Block a user