【发布时间】:2021-04-17 06:43:28
【问题描述】:
我一直在尝试使用 Ansible Python API,如他们的 official docs here 中所述。问题是,当我调用 main() 时,Ansible 返回一个错误:
the connection plugin '<class 'ansible.utils.sentinel.Sentinel'>' was not found
我正在运行 ansible-base 版本 2.10.8。
我已经被这个问题困扰了两天了。我在 Ansible 的 github page here 看到有人遇到同样的问题,他们似乎甚至不支持自己的 Python API。
谁能建议我如何解决这个问题?
【问题讨论】:
-
it seems they don't support their own Python API=> 在您在第一段中链接的文档顶部的注释中:This API is intended for internal Ansible use. Ansible may make changes to this API at any time that could break backward compatibility with older versions of the API. Because of this, external use is not supported by Ansible -
既然你问了一个建议:不要在你的外部项目中使用 ansible 内部 python API。
-
是的。我知道这一点,并且我确实尝试过首先与 ansible-runner 合作。但是,ansible-runner 在 stdout 键中返回一组带有 ansible 结果的嵌套字典。这不完全是我需要的。这是说使用实际的 API 是没有希望的吗?
-
是的,我已经尝试过 ansible-runner 解决方案。
-
好吧,这就是我的想法:我们遇到了 X/Y 问题。将 stdout 回调更改为适合您的需求。这里有一些信息docs.ansible.com/ansible/latest/plugins/callback.html。另请参阅此答案:stackoverflow.com/a/50017860/9401096
标签: python-3.x ansible