Help/Ansible/install_zabbix_agent.yaml
2025-05-29 21:55:04 +02:00

44 lines
1.3 KiB
YAML
Executable File

- name: Playbook to install zabbix
hosts: all
vars:
ipa: "hostvars[inventory_hostname]['ansible_default_ipv4']['address']"
become: true
gather_facts: yes
tasks:
- name: Install zabbix
apt:
name: zabbix-agent
state: present
- name: Copy agent config file
copy:
src: zabbix_agentd.conf
dest: /etc/zabbix/zabbix_agentd.conf
owner: root
group: root
mode: 0644
- name: zabbix restart
ansible.builtin.service:
name: zabbix-agent
state: restarted
enabled: true
- debug: var=hostvars[inventory_hostname]['ansible_default_ipv4']['address']
- name: Create a new host or update an existing host's info
local_action:
module: zabbix_host
server_url: https://zabbix.czech-tv.cz
login_user: ansict
login_password: Sojka123456
host_name: '{{inventory_hostname}}'
host_groups:
- Linux servers
link_templates:
- Linux by Zabbix agent
- SSH Service
interfaces:
- type: 1
main: 1
useip: 1
ip: "{{hostvars[inventory_hostname]['ansible_default_ipv4']['address']}}"
dns: "{{inventory_hostname}}"
port: 10050