• 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
  • 相关阅读:
    windows下用Python把pdf文件转化为图片(png格式)
    SQL优化实战:外层查询条件放到内层查询中(predicate push down)
    SQL优化实战:临时表+分批提交+按日结存
    SQL优化:重新编译存储过程和表
    论坛中的问题:47 数据库的事务是100%的吗?
    代理模式
    建造者模式
    工厂模式
    面向对向设计
    单例设计模式
  • 原文地址:https://www.cnblogs.com/patrick0715/p/7880178.html
Copyright © 2020-2023  润新知