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中.

相关文章:

  • 2021-05-13
  • 2022-12-23
  • 2021-08-15
  • 2022-02-14
  • 2021-04-12
  • 2022-12-23
  • 2021-12-12
猜你喜欢
  • 2021-11-26
  • 2021-12-29
  • 2021-08-10
  • 2022-12-23
  • 2021-07-31
  • 2021-06-06
  • 2021-11-18
相关资源
相似解决方案