adsasdasd

This commit is contained in:
2024-06-21 11:30:50 +02:00
parent 9c8402d6f0
commit 33d1956759
11 changed files with 315 additions and 13 deletions

62
zabbix_network.yml Normal file
View File

@@ -0,0 +1,62 @@
---
- name: Ensure Zabbix agent network configuration is correct
hosts: all
become: true
tasks:
- name: Open firewall port 10050 for Zabbix agent (Debian)
ansible.builtin.ufw:
rule: allow
port: 10050
proto: tcp
when: ansible_os_family == "Debian"
- name: Open firewall port 10050 for Zabbix agent (RedHat)
firewalld:
service: zabbix-agent
port: 10050/tcp
permanent: true
state: enabled
immediate: true
when: ansible_os_family == "RedHat"
- name: Restart firewall to apply changes (Debian)
ansible.builtin.service:
name: ufw
state: restarted
when: ansible_os_family == "Debian"
- name: Restart firewalld to apply changes (RedHat)
ansible.builtin.service:
name: firewalld
state: restarted
when: ansible_os_family == "RedHat"
- name: Create directory for Zabbix agent configuration if it does not exist
ansible.builtin.file:
path: /etc/zabbix/zabbix_agentd.d
state: directory
- name: Create directory for Zabbix agent logs if it does not exist
ansible.builtin.file:
path: /var/log/zabbix
state: directory
- name: Ensure /var/log/zabbix directory is owned by zabbix user
ansible.builtin.file:
path: /var/log/zabbix
owner: zabbix
group: zabbix
state: directory
- name: Ensure Zabbix agent is running
ansible.builtin.service:
name: zabbix-agent
state: restarted
- name: Check Zabbix agent status
ansible.builtin.command: systemctl status zabbix-agent
register: zabbix_status
- name: Debug Zabbix agent status
ansible.builtin.debug:
msg: "{{ zabbix_status.stdout_lines }}"