Ansible:使用集合时找不到模块



我正在与Ansible合作,我用一些角色制作了一个集合,一切都很完美,我可以使用我的角色等等,直到最近。

我尝试使用hashivault_write和hashivault_read模块(https://pypi.org/project/ansible-modules-hashivault/)但当我在我的收藏中的角色中使用它们时,它似乎不起作用。

ERROR! couldn't resolve module/action 'hashivault_write'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/home/xxxx/.ansible/collections/ansible_collections/xx/roles/roles/postfix/tasks/opendkim.yml': line 92, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
## Write opendkim private key in vault
- name: "Write in vault"
^ here

完全相同的角色在集合之外使用时(直接来自ansibleroles/文件夹(,我没有这个问题。我想问题不在于模块安装,因为它在集合之外工作。

在研究了Ansible集合的源代码和模块解析后,我了解到在集合内部,没有fqdn的模块或操作会在该集合上本地解析,或者它们的名称会附加到'Ansible.buildin'fqdn。

要解决这一僵局,有两种解决方案:

  • 添加"ansiblelegacy"fqdn,这将解析为";"遗留";通过pip 安装的模块

  • 在您的集合中创建一个"meta/runtime.yml",并添加一个重定向到";"遗留";模块

    ---
    plugin_routing:
    modules:
    hashivault_write:
    redirect: ansible.legacy.hashivault_write
    

最新更新