windows的vars在hosts文件不生效,就写了个脚本批量的添加hosts,懒的花时间找资料
政务云每次推送主机都生成新的host inventory文件,模版密码都一样,ip存放list.txt文件
#!/bin/bash read -p "请输入系统版本[windows/linux]: " version case $version in windows ) echo "[windows]" > /etc/ansible/hosts for ip in `cat list.txt` do echo "$ip ansible_ssh_user="Administrator" ansible_ssh_pass="模版密码" ansible_ssh_port=5985 ansible_connection="winrm" ansible_winrm_server_cert_validation=ignore" >> /etc/ansible/hosts done echo "/etc/ansible/hosts文件创建成功" cat /etc/ansible/hosts ;; linux ) echo "[linux]" > /etc/ansible/hosts for ip in `cat list.txt` do echo "$ip ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass='模版密码'" >> /etc/ansible/hosts done echo "/etc/ansible/hosts文件创建成功" cat /etc/ansible/hosts ;; * ) echo "请输入系统版本[windows/linux]" esac
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。