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

ansible之block实践--自动根据centos版本安装zabbix-agent

时间:2018-04-02 17:07:00      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:ansible block实践

block主体部分:

---
- block:
  - name: "复制zabbix_agent到主机"
    copy:
      src=zabbix-agent-3.0.5-1.el6.x86_64.rpm
      dest=/usr/local/src/
  - name: "安装zabbix_agent"
    yum:
      name: /usr/local/src/zabbix-agent-3.0.5-1.el6.x86_64.rpm
      state: present
  - name: "复制zabbix_agent配置文件"
    template:
      src=zabbix_agentd_centos6.conf.j2
      dest=/etc/zabbix/zabbix_agentd.conf
  - name: "启动zabbix,设置开机启动"
    service:
      name=zabbix-agent
      state=started
      enabled=yes
  when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "6"
- block:
  - name: "复制zabbix_agent到主机"
    copy:
      src=zabbix-agent-3.0.5-1.el7.x86_64.rpm
      dest=/usr/local/src/
  - name: "安装zabbix_agent"
    yum:
      name: /usr/local/src/zabbix-agent-3.0.5-1.el7.x86_64.rpm
      state: present
  - name: "复制zabbix_agent配置文件"
    template:
      src=zabbix_agentd_centos7.conf.j2
      dest=/etc/zabbix/zabbix_agentd.conf
  - name: "启动zabbix,设置开机启动"
    service:
      name=zabbix-agent
      state=started
      enabled=yes
  when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"


ansible之block实践--自动根据centos版本安装zabbix-agent

标签:ansible block实践

原文地址:http://blog.51cto.com/liuzhengwei521/2093876

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