ansible 批量安装zabbix agentd客户端
Posted Ca0Gu0
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible 批量安装zabbix agentd客户端相关的知识,希望对你有一定的参考价值。
目录结构
ansible/ ├── ansible.cfg ├── hosts ├── roles │ └── zabbix-agentd │ ├── files │ │ ├── install_zabbix.sh │ │ └── zabbix-3.0.1.tar.gz │ ├── handlers │ ├── tasks │ │ └── main.yml │ └── templates └── site.yml
[[email protected] ansible]# more site.yml --- - name: Install Zabbix-agentd hosts: zabbix-agentd remote_user: root roles: - zabbix-agentd
[[email protected] ansible]# more roles/zabbix-agentd/tasks/main.yml - name: copy zabbix_tar_gz to client copy: src=zabbix-3.0.1.tar.gz dest=/tmp/zabbix-3.0.1.tar.gz - name: copy install_shell to client copy: src=install_zabbix.sh dest=/tmp/install_zabbix.sh - name: install zabbix shell: /bin/bash /tmp/install_zabbix.sh
[[email protected] ansible]# more roles/zabbix-agentd/files/install_zabbix.sh #######client install############# yum install -y gcc make libselinux-python grep -q "zabbix" /etc/group GROUP_IS=$? if [ $GROUP_IS == 1 ];then groupadd zabbix fi grep -q "zabbix" /etc/passwd USER_IS=$? if [ $USER_IS == 1 ];then useradd -g zabbix zabbix -M -s /sbin/nologin fi mv /usr/local/zabbix /usr/local/zabbix_old-$(date +%Y%m%d) rm -rf /etc/zabbix cd /tmp tar zxvf zabbix-3.0.1.tar.gz cd zabbix-3.0.1 ./configure --prefix=/usr/local/zabbix --enable-agent make install ln -s /usr/local/zabbix/etc /etc/zabbix ln -s /usr/local/zabbix/sbin/zabbix_agentd /usr/local/sbin/ cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf-$(date +%Y%m%d) cat >/etc/zabbix/zabbix_agentd.conf<<EOF PidFile=/tmp/zabbix_agentd.pid LogFile=/tmp/zabbix_agentd.log Server=172.31.x.x ServerActive=172.31.x.x ListenPort=10050 ListenIP=0.0.0.0 EnableRemoteCommands=1 UnsafeUserParameters=1 LogFileSize=10 Timeout=30 #UserParameter=key,script EOF /etc/init.d/zabbix_agentd start chkconfig zabbix_agentd on
[[email protected] ansible]# ansible-playbook site.yml
以上是关于ansible 批量安装zabbix agentd客户端的主要内容,如果未能解决你的问题,请参考以下文章
ansible-playbook 批量安装zabbix_agent