安装软件
ansible host -m apt -a "name=zabbix-agent state=present"
ansible host -m shell -a "/sbin/ifconfig"
备份配置文件
ansible host -m shell -a "/bin/cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak"
查看更新会影响到的条数:
ansible host -m shell -a "/bin/cat /etc/zabbix/zabbix_agentd.conf|/bin/grep Server=127.0.0.1"
更新配置
ansible host -m shell -a "/bin/sed -i 's/Server=127.0.0.1/Server=10.8.0.231/g' /etc/zabbix/zabbix_agentd.conf "
重启服务
ansible host -m service -a "name=zabbix-agent state=restarted"