61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
---
|
|
- name: Instalar y configurar Zabbix Agent2 en Debian Bookworm
|
|
hosts: all
|
|
become: yes
|
|
tasks:
|
|
- name: Agregar clave GPG del repositorio Zabbix
|
|
apt_key:
|
|
url: "https://repo.zabbix.com/zabbix-official-repo.key"
|
|
state: present
|
|
|
|
- name: Agregar repositorio Zabbix para Debian Bookworm
|
|
apt_repository:
|
|
repo: 'deb http://repo.zabbix.com/zabbix/7.4/debian bookworm main'
|
|
state: present
|
|
filename: zabbix
|
|
|
|
- name: Actualizar caché de APT
|
|
apt:
|
|
update_cache: yes
|
|
|
|
- name: Instalar zabbix-agent2
|
|
apt:
|
|
name: zabbix-agent2
|
|
state: present
|
|
|
|
- name: Descargar configuración personalizada de zabbix_agent2.conf
|
|
get_url:
|
|
url: "https://git.capsulecorp.duckdns.org/keteflips/ansible/raw/branch/main/zabbix/config/zabbix_agent2.conf"
|
|
dest: "/etc/zabbix/zabbix_agent2.conf"
|
|
mode: '0644'
|
|
|
|
- name: Modificar systemd file para que zabbix-agent2 arranque como root (User)
|
|
lineinfile:
|
|
path: "/lib/systemd/system/zabbix-agent2.service"
|
|
regexp: '^User='
|
|
line: 'User=root'
|
|
backup: yes
|
|
|
|
- name: Modificar systemd file para que zabbix-agent2 arranque como root (Group)
|
|
lineinfile:
|
|
path: "/lib/systemd/system/zabbix-agent2.service"
|
|
regexp: '^Group='
|
|
line: 'Group=root'
|
|
backup: yes
|
|
|
|
- name: Recargar systemd para aplicar cambios
|
|
command: systemctl daemon-reload
|
|
notify: restart zabbix-agent2
|
|
|
|
- name: Habilitar y arrancar zabbix-agent2
|
|
systemd:
|
|
name: zabbix-agent2
|
|
enabled: yes
|
|
state: started
|
|
|
|
handlers:
|
|
- name: restart zabbix-agent2
|
|
systemd:
|
|
name: zabbix-agent2
|
|
state: restarted
|