并发取网段的ip地址并生成ansible的hosts
配置文件分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
相关推荐
laisean 2020-09-27
onepiecedn 2020-10-29
guchengxinfen 2020-10-12
houdaiye 2020-09-23
逆时针 2020-08-19
pzczyy 2020-08-19
annan 2020-08-02
hpujsj 2020-07-26
annan 2020-07-18
逆时针 2020-06-21
annan 2020-06-20
逆时针 2020-06-14
逆时针 2020-06-14
awoyaoc 2020-06-12
逆时针 2020-06-09
piaotiejun 2020-06-07
awoyaoc 2020-06-07