配置文件分ip和ansible_hosts,生成完成后需手动导入以免报错
#!/bin/bash
Usage(){
echo $"USAGRE:/bin/bash $0"
exit 1
}
if [ "$#" -ne "0" ];then
Usage
fi
CMD="ping -w 2 -c 2"
IP="192.168.1."
for n in `seq 1 254`
do
{
$CMD $IP$n &> /dev/null
if [ $? -eq 0 ];then
echo "$IP$n" >> /root/ip
fi
}&
done
sleep 3
for i in `cat /root/ip`
do
echo "$i ansible_ssh_host=$i ansible_ssh_user=root ansible_ssh_pass=密码 ansible_ssh_port=22" >> ansible_hosts
done
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。