Ansible/playbooks/zabbix_agent_install.yml

53 lines
1.2 KiB
YAML
Raw Normal View History

2024-02-10 09:25:27 +00:00
---
- name: "Zabbix agent2 installation and setup"
hosts: Rack
become: yes
vars_files:
- ../vaults/zabbix.yml
vars:
- zabbix_version: 6.4
- zabbix_server: 192.168.1.161
- host_meta: OrangePiZero Rack
tasks:
- name: Upgrade zabbix-release
2024-02-22 22:03:51 +00:00
ansible.builtin.apt:
2024-02-10 09:25:27 +00:00
name: zabbix-release
state: latest
- name: uninstall zabbix agent
2024-02-22 22:03:51 +00:00
ansible.builtin.apt:
2024-02-10 09:25:27 +00:00
name: zabbix-agent
state: absent
- name: install zabbix agent2
2024-02-22 22:03:51 +00:00
ansible.builtin.apt:
2024-02-10 09:25:27 +00:00
name: zabbix-agent2
state: latest
- name: Configure zabbix agent service
ansible.builtin.template:
2024-02-10 11:10:08 +00:00
src: ../templates/zabbix_agentd2.j2
2024-02-10 09:25:27 +00:00
dest: /etc/zabbix/zabbix_agent2.conf
owner: zabbix
group: zabbix
mode: '0644'
backup: yes
2024-02-22 22:05:08 +00:00
- name: Copy zabbix key
2024-02-10 12:06:07 +00:00
ansible.builtin.copy:
content: "{{ psk_key }}"
dest: /etc/zabbix/key.psk
2024-02-10 09:25:27 +00:00
- name: Create a config directory
ansible.builtin.file:
path: /etc/zabbix/zabbix_agentd.conf.d/
state: directory
mode: '0755'
- name: Restart zabbix agent
ansible.builtin.service:
name: zabbix-agent2
state: restarted
enabled: yes