顺德公农庄 发表于 2018-7-29 09:23:47

centos6 ansible_playbook编译安装zabbix客户端

#!/bin/bash  
a=`cat /etc/passwd | grep zabbix | wc -l`
  
if [ $a == 0 ];then
  
       useradd-s /sbin/nologin zabbix
  
fi
  
# catjinjia_zabbix.yaml
  
- hosts: webserver
  
tasks:
  
-name: install zabbix package
  
   yum: name={{ item }} state=latest
  
   with_items:
  
    -make
  
    -gcc
  
    -curl-devel
  
    -curl
  
-name: copy pack to client
  
   tags: copy_pack
  
   copy: src=/usr/local/src/zabbix-3.2.7.tar.gzdest=/usr/local/src/zabbix-3.2.7.tar.gz
  
-name: tar zabbix
  
   tags: tar
  
   shell: cd /usr/local/src/;tar -xf zabbix-3.2.7.tar.gz
  
-name: copy create_users.sh
  
   tags: copy_users
  
   copy: src=/etc/ansible/create_users.shdest=/usr/local/src/create_users.sh
  
-name: create users_zabbix
  
   tags: users
  
   shell: /bin/bash /usr/local/src/create_users.sh
  
-name: configure zabbix
  
   tags: config
  
   shell: cd /usr/local/src/zabbix-3.2.7;./configure --with-net-snmp--with-libcurl --enable-agent --prefix=/usr/local/zabbix
  
-name: make make install
  
   tags: make
  
   shell: cd /usr/local/src/zabbix-3.2.7;make && make install
  
-name: change agented
  
   tags: change
  
   shell: cp/usr/local/src/zabbix-3.2.7/misc/init.d/fedora/core5/zabbix_agentd/etc/init.d/;chmod 700 /etc/init.d/zabbix_agentd
  
-name: copy zabbix_agented
  
   tags: copy_agented
  
   copy: src=/etc/init.d/zabbix_agentd dest=/etc/init.d/zabbix_agentd
  
-name: copy zabbix_agented,conf
  
   tags: copy_conf
  
   copy: src=/usr/local/zabbix/etc/zabbix_agentd.confdest=/usr/local/zabbix/etc/zabbix_agentd.conf
  
-name: start zabbix_agented
  
   tags: start zabbix_agented
  
    shell:/etc/init.d/zabbix_agentd start;chkconfig zabbix_agentd on
页: [1]
查看完整版本: centos6 ansible_playbook编译安装zabbix客户端