ansible 批量安装zabbix客户端

1.先上本次安装部署的流程图

 省略zabbix-server安装部分

2.分发秘钥 批量安装

2.1 脚本

#!/bin/bash
. /etc/rc.d/init.d/functions
for ip in `cat /root/list.txt`
do
  echo ====分发Key $ip====
   sshpass -pWangjubao#crm2019 ssh-copy-id -o "StrictHostKeyChecking no"  -i /root/.ssh/id_dsa.pub root@$ip &>/dev/null
if [ $? -eq 0 ];then
action  "正在分发 $ip"  /bin/true
else
action  "分发失败 $ip"  /bin/false
fi
done

2.2anble—ploybook 安装客户端

- hosts: zabbx-agent 
  vars:
    - zabbix_server: 192.168.17.16
  tasks:
    - name: Installed zabbix_agent Yum
      yum:
        name: https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.15-1.el7.x86_64.rpm
        state: present
    - name: Copy zabbix_Agent configure
      template:
        src: ./zabbix_agentd.conf 
        dest: /etc/zabbix/zabbix_agentd.conf 


    - name:  Start zabbix_agent 
      systemd:
        name: zabbix-agent
        state: started
        enabled: yes

New :目前只有template支持带有变量的 copy目前不支持

  1. zabbix 自动发现

 

4.钉钉告警

优化

04.27日 完善zabbix客户端安装和Web Ui 自动注册及Grafana 展示 及MySQL连接数优化;

04.29日 完善钉钉告警脚本通知

05.6 日 自定义监控项磁盘清理已完成( >80 严重) 

原文地址:https://www.cnblogs.com/sseban/p/13048429.html