first commit

This commit is contained in:
2026-03-13 08:38:01 -04:00
commit a1b2b4dd8f
8 changed files with 296 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
---
- name: Get Ubuntu codename
ansible.builtin.command: lsb_release -cs
register: ubuntu_codename
changed_when: false
- name: Download Zabbix repository package
ansible.builtin.get_url:
url: "https://repo.zabbix.com/zabbix/{{ zabbix_version }}/ubuntu/pool/main/z/zabbix-release/zabbix-release_{{ zabbix_release }}+ubuntu{{ zabbix_ubuntu_version }}_all.deb"
dest: /tmp/zabbix-release.deb
mode: '0644'
- name: Install Zabbix repository package
ansible.builtin.apt:
deb: /tmp/zabbix-release.deb
- name: Install Zabbix agent2
ansible.builtin.apt:
name: zabbix-agent2
state: present
update_cache: true
- name: Configure Zabbix server address
ansible.builtin.lineinfile:
path: /etc/zabbix/zabbix_agent2.conf
regexp: '^Server='
line: "Server={{ zabbix_server }}"
- name: Configure Zabbix active server address
ansible.builtin.lineinfile:
path: /etc/zabbix/zabbix_agent2.conf
regexp: '^ServerActive='
line: "ServerActive={{ zabbix_server }}"
- name: Configure Zabbix agent hostname
ansible.builtin.lineinfile:
path: /etc/zabbix/zabbix_agent2.conf
regexp: '^Hostname='
line: "Hostname={{ ansible_hostname }}"
- name: Enable and start Zabbix agent2
ansible.builtin.systemd:
name: zabbix-agent2
state: started
enabled: true
daemon_reload: true