批量安装 zabbix-agent
借助 ansible 批量安装 zabbix-agent 客户端实现自动注册 完成批量监控服务器
首先需要在 zabbix-server 配置好主机发现规则,和发现动作,检测类型为检测 zabbix-agent 客户端
所以需要在需要被注册的主机上安装好 zabbix-agent ,配置好配置文件的目标管理主机,然后启动客户机就可以
5.1 配置主机群组,我使用all
5.2 编写剧本
- hosts: all
tasks:
#- name: 01更换下载源为阿里云,已经做了
- name: installed zabbix-agent2
get_url: url=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm dest=/etc/yum.repos.d validate_certs=no
- name: change source-1
shell: sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/' /etc/yum.repos.d/zabbix.repo
- name: chang source-2
shell: sed -i '11s/enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo
- name: install
yum: name=zabbix-agent2 state=installed
- name: change zabbix conf
file: src=../ansible-file/zabbix_agent2.conf dest=/etc/zabbix/zabbix_agent2.conf force=yes
- name: start zabbix-agent2
systemd: name=zabbix-agent2 state=started enabled=yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
5.3 运行结果

在被管理机器查看 agent 状态
