码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-09-30 21:28:33      阅读:412      评论:0      收藏:0      [点我收藏+]

标签:ansible   root   serve   art   star   chkconfig   task   play   print   

- 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

标签:ansible   root   serve   art   star   chkconfig   task   play   print   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!