zoukankan      html  css  js  c++  java
  • ansible批量部署zabbix-agent

    zabbix_agent.yml文件:

    ---
    - hosts: zabbix-agent
      vars:
        - zabbix_server: 192.168.1.100
      tasks:
        - name: add zabbix repo - Centos7
          yum_repository:
            name: zabbix
            description: zabbix repo
            baseurl: http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/ 
            gpgcheck: no
            enabled: 1
          when: ansible_distribution == "CentOS" and ansible_distribution_major_version == '7'
    
        - name: add zabbix repo - Centos6
          yum_repository:
            name: zabbix
            description: zabbix repo
            baseurl: http://repo.zabbix.com/zabbix/4.0/rhel/6/$basearch/ 
            gpgcheck: no
            enabled: 1
          when: ansible_distribution == "CentOS" and ansible_distribution_major_version == '6'
         
        - name: Install zabbix agent
          yum: name=zabbix-agent state=present
        - name: copy zabbix agent
          template: src=zabbix_agentd.conf.j2 dest=/etc/zabbix/zabbix_agentd.conf
        - name: start zabbix agent
          service: name=zabbix-agent state=started enabled=true

    zabbix_agentd.conf.j2文件内容

    PidFile=/var/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    DebugLevel=3
    Server={{ zabbix_server }}
    ListenPort=10050
    ListenIP={{ ansible_default_ipv4.address }}
    ServerActive={{ zabbix_server }}
    Hostname={{ ansible_default_ipv4.address }} 
    HostMetadataItem=system.uname
    Include=/etc/zabbix/zabbix_agentd.d/*.conf
    # UserParameter=
  • 相关阅读:
    XML认识
    servlet清晰理解
    JDBC基本知识
    JSP中的路径
    JavaBean基础
    JSP执行过程详解
    JDBC连接mysql
    JSP简易留言板
    Jmeter性能测试之基础知识(一)
    linux下安装redis并开机自启动
  • 原文地址:https://www.cnblogs.com/zhangzihong/p/9829525.html
Copyright © 2011-2022 走看看