首页 > 解决方案 > Ansible:并行部署剧本时出错

问题描述

我正在用 ansible 建立一个 kubernetes 集群。这运行良好。

现在我通常有 2 或 3 个集群,我可以用它来测试不同的东西。

通常它发生在集群/服务器损坏的某个时间点。如果发生这种情况,我通常会重新创建服务器并重新启动剧本。因为这需要一些时间,所以我希望能够并行运行 2 个或更多剧本。

但每次我这样做时,我都会收到以下错误:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory

我像这样运行我的剧本:

  "$ansible_playbook"
    -i "${ANSIBLE_HOSTS}"
    "${ANSIBLE_YML}"
    --flush-cache
    --user root
    --become
    --become-user root
    --ask-sudo-pass

错误的原因可能是什么?

我可以想象,ansible 在后台创建了一些文件,供不同的剧本使用。但那可能是哪些文件?

提前谢谢!

更新更详细的错误日志 (-vvv)

ansible-playbook 2.7.8
  config file = /home/mod/cod/wo/thingylabs/kubernetes-provisioning/playbooks/test1/ansible.cfg
  configured module search path = ['/home/mod/cod/wo/thingylabs/kubernetes-provisioning/vendors/kubespray/library']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.7.2 (default, Jan 10 2019, 23:51:51) [GCC 8.2.1 20181127]
Using /home/mod/cod/wo/thingylabs/kubernetes-provisioning/playbooks/test1/ansible.cfg as config file
SUDO password:
ERROR! Unexpected Exception, this is probably a bug: [Errno 2] No such file or directory
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", 
    exit_code = cli.run()
  File "/usr/lib/python3.7/site-packages/ansible/cli/playbook.py", line 104, in run
    loader, inventory, variable_manager = self._play_prereqs(self.options)
  File "/usr/lib/python3.7/site-packages/ansible/cli/__init__.py", line 786, in _play_prereqs
    inventory = InventoryManager(loader=loader, sources=options.inventory)
  File "/usr/lib/python3.7/site-packages/ansible/inventory/manager.py", line 148, in __init__
    self.parse_sources(cache=True)
  File "/usr/lib/python3.7/site-packages/ansible/inventory/manager.py", line 207, in parse_sources
    source = unfrackpath(source, follow=False)
  File "/usr/lib/python3.7/site-packages/ansible/utils/path.py", line 47, in unfrackpath
    basedir = op.getcwd()
FileNotFoundError: [Errno 2] No such file or directory

标签: ansible

解决方案


推荐阅读