ansible-modules-hashivault icon indicating copy to clipboard operation
ansible-modules-hashivault copied to clipboard

Cannot access hashivault modules in a collection

Open a01fe opened this issue 3 years ago • 3 comments

I have ansible-modules-hashivault installed in a venv, playbooks running in that venv find hashivault modules okay. References to hashivault module references in from a role in a collection get an error:

ERROR! couldn't resolve module/action 'hashivault_secret'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/Users/xxx/Projects/ansible/collections/ansible_collections/yyy/zzz/roles/vault/tasks/initialize.yaml': line 33, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: Save root token in bootstrap vault
      ^ here

a01fe avatar Mar 27 '22 17:03 a01fe

I found a workaround here: https://stackoverflow.com/questions/65608888/ansible-module-not-found-when-using-collection

In meta/runtime.yml inside my collection, adding the following fixes the error:

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

a01fe avatar Mar 27 '22 22:03 a01fe

Might be something could be done here

TerryHowe avatar Mar 28 '22 14:03 TerryHowe

@a01fe Thanks for that find, that saved a huge problem for us!

The main underlying issue is that collections cannot depend on roles in ansible (apparently by design: https://stackoverflow.com/a/69559820/4185785). :/

pat-s avatar Jan 06 '23 10:01 pat-s