您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。