ricardoklein.ansible_zabbix_agent
kleinstuff.zabbix-agent
This project installs the Zabbix agent (version 6.4) by default. It currently supports OpenSuse and Suse Enterprise 15.
Requirements
To use this role, you need the following collections:
- community.zabbix version 1.9.3
- ansible.posix version 1.3.0
- community.general version 3.7.0
Role Variables
Most settings can be found in defaults/main.yml
. You can check there and override them in your variable files.
However, you must set the Zabbix server address using ansible_zabbix_agent__ServerAddr
.
If you want to add hosts to the Zabbix server, you need to set some additional variables:
# (OPTIONAL) Service name; set to "zabbix_agentd" for older package versions
zabbix_service_name: "zabbix-agent"
# Enable the feature to add hosts to the server
ansible_zabbix_agent__add_hosts_to_server: True
# Add your API Token for the Zabbix server
# Always encrypt this value using ansible-vault or similar methods
ansible_zabbix_agent__Server_auth_key: "your_super_secret_token"
# Set the group name(s) (can set these in group_vars or host_vars)
ansible_zabbix_agent__Groups:
- some_zabbix_group_name
# Set the template(s) (can set these in group_vars or host_vars)
ansible_zabbix_agent__Templates:
- "Template 1"
- "Template 2"
# OPTIONAL: Define host Macros
ansible_zabbix_agent__zabbix_macros:
- { macro: "{$A_MACRO}", value: "{{ a_host_var }}" }
- { macro: "{$ANOTHER_MACRO}", value: "a-simple-string" }
- { macro: "{$CONFIGURED_BY}", value: "Ansible" }
# OPTIONAL: Define host TAGs
ansible_zabbix_agent__zabbix_tags:
- "OneTag"
- "AnotherTag"
By default, the monitored machine's hostname is set as {{ ansible_host }}
, but you can change this with ansible_zabbix_agent__Hostname
for each host.
If you are using openSUSE Tumbleweed, the default package (as of June 4, 2023) names the Zabbix service zabbix_agentd
instead of zabbix-agent
. In this case, set zabbix_service_name: "zabbix_agentd"
in your host variables.
Dependencies
You need the following collections:
- community.zabbix version 1.9.3
- ansible.posix version 1.3.0
- community.general version 3.7.0
Example Playbook
Here’s an example playbook:
- hosts: servers
roles:
- { role: kleinstuff.zabbix-agent, ansible_zabbix_agent__ServerAddr: 'youzabbixserver.example.com' }
License
This project is licensed under the GPL.
Author Information
If you have suggestions for improvements or want to request new features, please feel free to create an issue or submit a pull request.
Role to install and configure zabbix-agent on Linux
ansible-galaxy install ricardoklein.ansible_zabbix_agent