• ansible 一键安装zabbix client


    目录结构
    # tree ansible-zabbix-playbook
    ├── hosts
    ├── roles
    │   └── zabbix
    │       ├── files
    │       │   └── zabbix-3.4.2.tar.gz
    │       ├── tasks
    │       │   └── main.yml
    │       └── vars
    ├── zabbix.retry
    └── zabbix.yml

    执行命令

    ansible-playbook -e server_ip=10.19.161.17 zabbix.yml -i hosts

    # cat ansible-zabbix-playbook/roles/zabbix/tasks/main.yml
    - name: copy
      copy: src=zabbix-3.4.2.tar.gz dest=/tmp/zabbix-3.4.2.tar.gz
    - name: tar zabbix
      shell: cd /tmp/;tar zxf zabbix-3.4.2.tar.gz
    - name: group add
      shell: groupadd zabbix
    - name: useradd
      shell: useradd  -g zabbix -s /sbin/nologin zabbix
    - name: yum
      yum: name={{ item }} state=latest
      with_items:
      - make
      - gcc
      - curl
      - curl-devel
      - pcre-devel
    - name: configure
      shell: cd /tmp/zabbix-3.4.2;./configure --with-net-snmp --with-libcurl --enable-agent --prefix=/usr/local/zabbix;make && make install
    - name: zabbix script
      shell: cp /tmp/zabbix-3.4.2/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
    - name: authority
      shell: chmod 755 /etc/init.d/zabbix_agentd
    - name: chkconfig add
      shell: chkconfig --add zabbix_agentd;chkconfig zabbix_agentd on
    - name: vim zabbix_agent
      shell: sed -i 's/ZABBIX_BIN="/usr/local/sbin/zabbix_agentd"/ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"/g' /etc/init.d/zabbix_agentd
    - name: vim_conf
      shell: sed -i 's/Server=127.0.0.1/Server={{ server_ip }}/g' /usr/local/zabbix/etc/zabbix_agentd.conf
    - name: vim_conf
      shell: sed -i "s/Hostname=Zabbix server/Hostname=$(hostname)/g" /usr/local/zabbix/etc/zabbix_agentd.conf
    - name: quanxian
      shell: chown -R zabbix.zabbix /usr/local/zabbix
    - name: restart_server
      shell: /etc/init.d/zabbix_agentd restart
  • 相关阅读:
    开发一个基于 Android系统车载智能APP
    Xilium.CefGlue利用XHR实现Js调用c#方法
    WPF杂难解 奇怪的DisconnectedItem
    (转)获取安卓iOS上的微信聊天记录、通过Metasploit控制安卓
    mac 安装npm
    mac安装Homebrew
    关于面试,我也有说的
    【分享】小工具大智慧之Sql执行工具
    领域模型中分散的事务如何集中统一处理(C#解决方案)
    小程序大智慧,sqlserver 注释提取工具
  • 原文地址:https://www.cnblogs.com/patrick0715/p/7880178.html
Copyright © 2020-2023  润新知