發現在刪掉 ~/.ssh/know_hosts 之后運行 ansible api 會出現以下提示
The authenticity of host '10.1.*.* (10.1.*.*)' can't be established. RSA key fingerprint is 43:54:a5:c0:f8:4a:a2:d2:1a:ef:87:8f:90:f5:dd:4a. Are you sure you want to continue connecting (yes/no)?
因為在腳本里面自動運行調用,無法使用 pexpect 模塊,也無法捕捉到 這段提示的輸出,ansible 源碼研究不夠透徹搞了半天也沒解決,最后只能從根本途徑上面解決問題,直接修改 ssh 配置,去掉該段提示。
vim /etc/ssh/ssh_config Host * StrictHostKeyChecking no
重啟 sshd
service sshd restart