ansible之block實踐--自動根據centos版本安裝zabbix-agent
阿新 • • 發佈:2018-04-02
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