ansible批量安装zabbix_agent && 修改配置文件

Ansible常用指令

 

 

rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-release-4.0-1.el6.noarch.rpm

 

 

yum install zabbix-agent -y

 

vi /etc/zabbix/zabbix_agentd.conf

 

 

 

 

ServerActive=127.0.0.1

 

Hostname=Zabbix server

Server=127.0.0.1

 

zabbix-agent部署

ansible dev3 -m shell -a ‘’     查看配置可用shell模块

ansible dev3 -m lineinfile -a 'path=/etc/zabbix/zabbix_agentd.conf regexp="^ServerActive=" line="ServerActive=172.17.31.76:10051"'    替换远程文件内容

ansible dev3 -m lineinfile -a 'path=/etc/zabbix/zabbix_agentd.conf regexp="^Server=" line="Server=127.0.0.1,172.17.31.76"'      替换远程文件内容

 

Copy  script  yum vars 等常用模块,适用yml文件

命令行直接使用shell模块简单粗暴。

 

 

 

 

原文地址:https://www.cnblogs.com/mybxy/p/10312911.html