使用ansible-playbook部署zabbix-agent-4.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

转载于:https://blog.51cto.com/10880347/2287898

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值