ansible自动化监控
编写ansible
编辑hosts文件
[root@ansible ~]# cat zabbix-agent/hosts
[webservers]
172.16.1.7
172.16.1.8
[dbservers]
172.16.1.51
[root@ansible ~]#
编写ansible
- hosts: all
vars:
- Zabbix_Server_IP: 172.16.1.71
tasks:
- name: install zabbixagent2
yum:
name: https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-agent2-5.0.15-1.el7.x86_64.rpm
state: present
- name: configure zabbixagent2.conf
template:
src: ./files/zabbix_agent2.conf.j2
dest: /etc/zabbix/zabbix_agent2.conf
notify: restart zabbix agent2
- name: configure zabbixagent2.conf userparameter
copy:
src: ./files/zabbix_agent2.d/
dest: /etc/zabbix/zabbix_agent2.d/
notify: restart zabbix agent2
- name: systemd zabbixagent2
systemd: