Ansible 自动化安装zabbix-agent客户端
1、主控端安装ansible
#yum -y install ansible
2、配置ansible环境
#cd /opt
#vim ansible.cfg
[defaults]
inventory = ./inventory
#vim inventory
[zabbix_agent]
10.106.10.[163:193]
测试
#ansible zabbix_agent -m ping
3、批量配置zabbix的yum源
下载zabbix.repo到/etc/yum.repos.d/zabbix.repo
#ansible zabbix_agent -a "wget -P /etc/yum.repos.d/ ftp://10.196.80.234/zabbix/zabbix.repo"
#ansible zabbix_agent -a "yum clean all"
#ansible zabbix_agent -a "yum makecache"
#ansible zabbix_agent -a "yum -y install zabbix-agent"
4、批量配置zabbix-agent客户端
#ansible zabbix_agent -a "sed -i 's/Server=127.0.0.1/Server=10.196.80.29/g' /etc/zabbix/zabbix_agentd.conf"
#ansible zabbix_agent -a "sed -i 's/ServerActive=127.0.0.1/\#ServerActive=127.0.0.1/g' /etc/zabbix/zabbix_agentd.conf"
#ansible zabbix_agent -a "systemctl status zabbix-agent"
#ansible zabbix_agent -a "systemctl enable zabbix-agent"
#ansible zabbix_agent -a "systemctl restart zabbix-agent"
5、批量上传配置文件
#ansible zabbix_agent -a "wget -P /etc/zabbix/zabbix_agentd.d/ ftp://10.106.10.234/zabbix-azzl/conf/tcp.conf"