-
-
Save a1ad/e426218af83915474da4b05852b551a0 to your computer and use it in GitHub Desktop.
Example of Ansible playbook for installing and configuring the Zabbix agent in a host and then creating the host in a Zabbix server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Install the Zabbix agent | |
yum: | |
name: http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.8-1.el7.x86_64.rpm | |
- name: Configure the Zabbix agent | |
replace: | |
path: /etc/zabbix/zabbix_agentd.conf | |
regexp: '{{item.regexp}}' | |
replace: '{{item.replace}}' | |
with_items: | |
- {regexp: "^Server=127.0.0.1$", replace: "Server={{zabbix_server}}"} | |
- {regexp: "^ServerActive=127.0.0.1$", replace: "ServerActive={{zabbix_server}}"} | |
- {regexp: "^Hostname=Zabbix server$", replace: "Hostname={{ansible_hostname}}"} | |
vars: | |
- zabbix_server: zabbix-server.brazilsouth.cloudapp.azure.com | |
- name: Start the Zabbix agent service | |
service: | |
name: zabbix-agent | |
state: started | |
enabled: yes | |
- name: Create a new host or update an existing host's info | |
local_action: | |
module: zabbix_host | |
server_url: http://zabbix-server.brazilsouth.cloudapp.azure.com | |
login_user: zabbix-admin | |
login_password: zabbix-admin-password | |
host_name: '{{ansible_hostname}}' | |
host_groups: | |
- Virtual machines | |
- Azure - Cluster Kubernetes | |
link_templates: | |
- Template OS Linux | |
- Template App Docker | |
interfaces: | |
- type: 1 | |
main: 1 | |
useip: 1 | |
ip: '{{ansible_ssh_host}}' | |
dns: "" | |
port: 10050 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment