首页 > 其他 > 详细

使用ansible-playbook部署zabbix-agent-4.0

时间:2018-09-30 21:10:54      阅读:275      评论:0      收藏:0      [点我收藏+]
- hosts: all remote_user: root tasks: - name: CentOS6 system copy zabbix-agent rpm copy: src=/tmp/zabbix-agent-3.4.9-1.el6.x86_64.rpm dest=/tmp/zabbix-agent-3.4.9-1.el6.x86_64.rpm when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "6" - name: CentOS7 system copy zabbix-agent rpm copy: src=/tmp/zabbix-agent-3.4.9-1.el7.x86_64.rpm dest=/tmp/zabbix-agent-3.4.9-1.el7.x86_64.rpm when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "7" - name: yum install zabbix-agent shell: cd /tmp;yum -y localinstall zabbix-agent-3.4.*.rpm - name: rm zabbix-agent shell: cd /tmp;rm -rf zabbix-agent-3.*.rpm - name: configure Server IP shell: sed -i ‘s/Server=127.0.0.1/Server=192.168.58.58/‘ /etc/zabbix/zabbix_agentd.conf - name: configure ServerActive IP shell: sed -i ‘s/ServerActive=127.0.0.1/ServerActive=192.168.58.58/‘ /etc/zabbix/zabbix_agentd.conf - name: configure HostMetadata shell: sed -i ‘s/# HostMetadata=/HostMetadata=qas/‘ /etc/zabbix/zabbix_agentd.conf - name: CentOS6 system configure Hostname shell: host=`ifconfig |awk -F ‘[ :]+‘ ‘NR==2 {print $4}‘`;sed -i ‘s/Hostname=Zabbix server/Hostname=‘$host‘/‘ /etc/zabbix/zabbix_agentd.conf when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "6" - name: CentOS7 system configure Hostname shell: host=`ifconfig |awk -F ‘[ :]+‘ ‘NR==2 {print $3}‘`;sed -i ‘s/Hostname=Zabbix server/Hostname=‘$host‘/‘ /etc/zabbix/zabbix_agentd.conf when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "7" - name: CentOS6 system start zabbix shell: /etc/init.d/zabbix-agent start;chkconfig zabbix-agent on when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "6" - name: CentOS7 system start zabbix shell: systemctl enable zabbix-agent.service;systemctl restart zabbix-agent.service when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "7"

git仓库地址

https://github.com/xgh2016/ansible-zabbix

使用ansible-playbook部署zabbix-agent-4.0

原文:http://blog.51cto.com/10880347/2287898

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!