ssh配置導致Ansible並發失敗


  Ansible並發失敗原因,  fork=100. 執行playbook時候沒有並發

vim /usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/ssh.py

299     ┊   if C.HOST_KEY_CHECKING and not_in_host_file:
300     ┊   ┊   # lock around the initial SSH connectivity so the user prompt about whether to add
301     ┊   ┊   # the host to known hosts is not intermingled with multiprocess output.
302     ┊   ┊   fcntl.lockf(self.runner.process_lockfile, fcntl.LOCK_EX)
303     ┊   ┊   fcntl.lockf(self.runner.output_lockfile, fcntl.LOCK_EX)
304          
305     ┊   # create process
306     ┊   (p, stdin) = self._run(ssh_cmd, in_data)

以上代碼可以看出, 如果ansible配置HOST_KEY_CHECKING=true. 並且要鏈接的機器沒有在~/.ssh/known_hosts里面, 一個進程就會鎖死~/.ssh/known_hosts文件. 這樣ansible就不能並發.

檢查自己的ssh conf. 發現"    UserKnownHostsFile /dev/null"

這樣就不會有機器在~/.ssh/known_hosts中, 所以每個task都不能並發.

最終解決方案:

host_key_checking = False 在ansible.cfg中.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM