ansible之block实践--自动根据centos版本安装zabbix-agent
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible之block实践--自动根据centos版本安装zabbix-agent相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章