zabbix_install.yml

[root@localhost ansible]# cat zabbix_install.yml
- hosts: 101.251.237.253
  tasks:
    - name: step1 
      ping:
    - name: step2 install zabbix3.4 source
      shell: rpm -qa|egrep "zabbix-release-3.4"|wc -l
      ignore_errors: True
      register: check_zabbix
    - name: step3 
      shell: rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
      when: check_zabbix == "0"
    - name: step4 install
      yum: name=zabbix-agent  state=installed
    - name: step5 iptables check
      shell: iptables -nL|grep "0.0.0.0"
      ignore_errors: True
      register: check_iptables
    - name: step6
      shell: iptables -I INPUT -p tcp -s 101.89.68.197 --dport 10050 -j ACCEPT
      when: check_iptables is succeeded
    - name: step7 check zabbix config file exits
      shell: ls -l /etc/zabbix/zabbix_agentd.conf 
      ignore_errors: True
      register: check_configfile
    - name: step8
      template: src=/config_file/ansible_config/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf
      when: check_configfile is succeeded 
    - name: step9
      service: name=zabbix-agent state=started

 

posted @ 2018-05-23 17:25  滴滴滴  阅读(294)  评论(0编辑  收藏  举报