Skip to content

Instantly share code, notes, and snippets.

@dynax60
Created October 8, 2018 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dynax60/ab43cc1b9e2402b98266a9f8be2aae06 to your computer and use it in GitHub Desktop.
Save dynax60/ab43cc1b9e2402b98266a9f8be2aae06 to your computer and use it in GitHub Desktop.
Install lastest zabbix-agent 4.0 with ansible
---
- hosts: myhosts
gather_facts: no
force_handlers: true
ignore_errors: no
tasks:
- name: get version of installed zabbix-agent
raw: rpm -qa zabbix-agent | cut -d'-' -f3
register: version
changed_when: false
- name: install zabbix 4.0 repository if it's not already installed
command: rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
when: version.stdout is not search("4.0")
args:
warn: false
- name: update zabbix-agent to latest version
yum:
name: zabbix-agent
state: latest
- name: copy a prepared zabbix-agent's config file to remote host
copy:
src: template/zabbix_agentd.conf
dest: /etc/zabbix/zabbix_agentd.conf
notify: restart zabbix-agent
- name: be sure zabbix-agent is running and enabled
service: name=zabbix-agent state=started enabled=yes
handlers:
- name: restart zabbix-agent
service: name=zabbix-agent state=restarted
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=3
Server=10.0.0.3
Include=/etc/zabbix/zabbix_agentd.d/*.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment