ZABBIX_AGENT.YML file:
----hosts:zabbix-Agent VARs:-Zabbix_server:192.168.1.100tasks:-Name:add Zabbix Repo-Centos7 Yum_repository:name:zabbix Description:zabbix repo baseurl:http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/Gpgcheck:no Enabled:1when:ansible_distribution=="CentOS"and ansible_distribution_major_version = ='7'-Name:add Zabbix Repo-Centos6 Yum_repository:name:zabbix Description:zabbix repo baseurl:http://repo.zabbix.com/zabbix/4.0/rhel/6/$basearch/Gpgcheck:no Enabled:1when:ansible_distribution=="CentOS"and ansible_distribution_major_version = ='6'-name:install Zabbix Agent Yum:name=zabbix-agent state=present-name:copy Zabbix Agent Template:src=zabbix_agentd.conf.j2 dest=/etc/zabbix/zabbix_agentd.conf-name:start Zabbix Agent Service:name=zabbix-agent state=started enabled=true
Zabbix_agentd.conf.j2 File Contents
pidfile=/var/run/zabbix/zabbix_agentd.pidlogfile=/var/log/zabbix/Zabbix_ Agentd.logdebuglevel=3Server={{zabbix_server}}listenport=10050 Listenip={{ansible_default_ipv4.address}}serveractive={{zabbix_server}}hostname= {{ansible_default_ipv4.address}} Hostmetadataitem=system.unameinclude=/etc/zabbix/zabbix_agentd.d/*. conf# Userparameter=
ansible Batch Deployment Zabbix-agent