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

用ansible部署zabbix_agent

时间:2017-08-16 20:14:32      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:not found   内容   check   ace   line   fan   led   ext   提示   

前期准备
批量配置yum源
ansible -i t4 st -m copy -a src=/opt/shell/yum/rhe65.repo dest=/tmp/ owner=watson group=watson mode=644 backup=yes
rhe65.repo文件内容:
[rhe65]
name=rhe65
baseurl=ftp://192.168.20.25/pub/rhel65/
gpgcheck=0
enabled=1
1、脚本准备好
#!/bin/bash
cd /tmp
wget ftp://192.168.20.25/zabbix/zabbix_agent.zip
unzip zabbix_agent.zip
mv zabbix_agent /usr/local/
mv zabbix_agentd /etc/init.d/
useradd zabbix
chmod 755 /etc/init.d/zabbix_agentd
cp /usr/local/zabbix_agent/sbin/zabbix_agentd /usr/local/sbin/
service zabbix_agentd start
rm -rf /tmp/zabbix_agent.zip
2、把脚本复制到远程主机
ansible -i /opt/shell/lizuofang/beleve/19/hosts_19 dev -m copy -a src=/opt/shell/zabbix/install_agent.sh dest=/tmp/ owner=watson group=watson mode=755 backup=yes
3、用root用户执行远程主机脚本
ansible -i /opt/shell/lizuofang/beleve/19/hosts_19 dev -m shell -a bash /tmp/install_agent.sh -K --become
错误1
"msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren‘t installed!"
cat t3 |grep FA|awk ‘{print $1}‘
ansible -i t2 sh -m shell -a yum install libselinux-python -y ‘ -K --become
yum install libselinux-python -y
错误2
/tmp/install_agent.sh: line 7: useradd: command not found
/tmp/install_agent.sh: line 10: service: command not found
j解决:
ansible -i t2 sh -m shell -a ‘yum install lsof -y ‘ -K --become#如果提示已经安装,没能解决就用下面的命令
ansible -i /opt/shell/lizuofang/beleve/19/hosts_19 dev -m shell -a ‘PAHT="/usr/local/sbin:/usr/sbin:/sbin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin";source /etc/profile;bash /tmp/install_agent.sh -K --become

出错原因在这里:ansible执行shell模块和command模块报错| FAILED | rc=127 >> /bin/sh: lsof: command not found和| rc=2 >> [Errno 2] No such file or directory

 下面出错同理
4、检查agent端口是否起来
ansible /opt/shell/lizuofang/beleve/19/hosts_19 dev -m shell -a ‘lsof -i:10050‘ -K --become
错误
/bin/sh: lsof: command not found
错误解决同上

用ansible部署zabbix_agent

标签:not found   内容   check   ace   line   fan   led   ext   提示   

原文地址:http://www.cnblogs.com/losbyday/p/7375320.html

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