semaphore/roles/zabbix_agent/tasks/main.yml
2024-08-12 01:22:12 +08:00

68 lines
1.8 KiB
YAML

- name: Download Zabbix2 for debian
ansible.builtin.apt:
deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian{{ ansible_distribution_major_version }}_all.deb
when: ansible_facts['distribution'] == "Debian"
- name: Download Zabbix2 for Ubuntu
ansible.builtin.apt:
deb: https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu{{ ansible_distribution_version }}_all.deb
when: ansible_facts['distribution'] == "Ubuntu"
- name: Run an apt update
ansible.builtin.apt:
update_cache: yes
changed_when: false
- name: Remove Zabbix-Agent package
ansible.builtin.apt:
name: zabbix-agent
state: absent
- name: Install Zabbix-Agent2 package
ansible.builtin.apt:
name: zabbix-agent2
state: present
- name: Install Zabbix-Agent2-plugin-mongodb package
ansible.builtin.apt:
name: zabbix-agent2-plugin-mongodb
state: present
- name: Install Zabbix-Agent2-plugin-postgresql package
ansible.builtin.apt:
name: zabbix-agent2-plugin-postgresql
state: present
- name: Enable service httpd and ensure it is not masked
ansible.builtin.systemd_service:
name: zabbix-agent2
enabled: true
masked: no
- name: Manage file /etc/zabbix/zabbix_agent2.conf
copy:
src: zabbix_agent2.conf.j2
dest: /etc/zabbix/zabbix_agent2.conf
owner: zabbix
group: zabbix
mode: 0644
notify: restart_zabbix
- name: Manage file /etc/zabbix/zabbix_agentd.psk
copy:
src: zabbix_agent2.psk
dest: /etc/zabbix/zabbix_agent2.psk
owner: zabbix
group: zabbix
mode: 0644
notify: restart_zabbix
- name: Create zabbix_agentd.conf.d directory if it does not exist
ansible.builtin.file:
path: /etc/zabbix/zabbix_agentd.conf.d/
state: directory
owner: zabbix
group: zabbix
mode: 0755
notify: restart_zabbix