标签:ansible +centos7 批量安装zabbix3.2.1 agent
ansible +centos7 批量不上zabbix agent
部署机器 192.168.4.100-116
zabbix 服务器ip192.168.4.117
ansible 结构说明
. ├── hosts # 部署客户端机器 ├── roles │ └── zabbix_agent │ ├── defaults │ ├── files │ ├── handlers │ ├── meta │ ├── tasks │ │ └── main.yml # ansible 部署zabbix_agent 脚本 │ ├── templates │ │ └── zabbix_agentd.conf.j2 # zabbix_agent 配置文件 │ └── vars └── zabbix_agent.yml # ansible 控制脚本
zabbix_agent.yml 内容说明 - hosts: code user: root vars: zabbix_serverip: 192.168.4.117 # zabbix 服务器IP zabbix_activeip: 192.168.4.117 # zabbix 服务器IP agent_ip: ‘{{ ansible_eth0.ipv4.address }}‘ # 客户端IP 根据实际情况修改自己的网卡名字eth0 改成自己服务器 roles: - zabbix_agent
main.yml 内容说明 - name: yum epel-release # 安装zabbix yum 源必须 yum: name=epel-release state=present - name: zabbix-release-3.2-1.el7.noarch.rpm get_url: url: #下载zabbix yum 源配置 dest: /tmp/zabbix-release-3.2-1.el7.noarch.rpm - name: rpm -qi zabbix-release-3.2-1.el7.noarch shell: rpm -qi zabbix-release-3.2-1.el7.noarch # 查看服务器是否安装zabbix3.2 register: result ignore_errors: True - name: zabbix-release-3.2-1.el7.noarch.rpm shell: rpm -Uvh /tmp/zabbix-release-3.2-1.el7.noarch.rpm # 安装zabbix 源码 when: result.rc == 1 - name: yum install zabbix-agent yum: name={{ item }} state=present # 安装zabbix-agent with_items: - zabbix-agent - zabbix-get - zabbix-sender - lineinfile: dest=/etc/services line="zabbix-agent 10050/tcp Zabbix Agent" - lineinfile: dest=/etc/services line="zabbix-agent 10050/udp Zabbix Agent" # 添加zabbix 端口到services 文件 - name: up zabbix-agent file client # 上传配置文件 template: src=zabbix_agentd.conf.j2 dest=/etc/zabbix/zabbix_agentd.conf - name: enabled service zabbix-agent # 打开zabbix-agent 开机启动 service: name=zabbix-agent.service enabled=yes - name: start service zabbix-agent # 启动zabbix-agent service: name=zabbix-agent state=started
其它说明:
ansible-playbook -i hosts zabbix_agent.yml -verbose
本文出自 “成长记录” 博客,请务必保留此出处http://juestnow.blog.51cto.com/1515305/1878420
ansible +centos7 批量安装zabbix3.2.1 agent
标签:ansible +centos7 批量安装zabbix3.2.1 agent
原文地址:http://juestnow.blog.51cto.com/1515305/1878420