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

ansible批量部署zabbix-agent

时间:2018-10-22 14:50:15      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:nbsp   template   repo   start   pid   art   ase   ansible批量   baseurl   

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=

 

ansible批量部署zabbix-agent

标签:nbsp   template   repo   start   pid   art   ase   ansible批量   baseurl   

原文地址:https://www.cnblogs.com/zhangzihong/p/9829525.html

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