playbook-valut error: Please pip install hvac to use the hashi_vault lookup module

Viewed 363
- name: Vault Test 
  set_fact:
    msg: "{{ lookup('hashi_vault', 'secret=secret token=token url=https://address')}}"

I hava a error when run this palybook:

fatal: [*****]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'hashi_vault'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Please pip install hvac to use the hashi_vault lookup module.. Please pip install hvac to use the hashi_vault lookup module."}

but I have installed the havc

ansible            5.9.0
ansible-core       2.12.7
hvac               0.10.8
pyhcl              0.4.4
1 Answers

I had the same problem. There is an issue closed in the ansible github about this: hashi_vault not recognizing hvac

Quoting:

depends on what Python install Ansible is using. Running:

ansible -m debug -a 'var=ansible_playbook_python' localhost

will show you what Ansible is using to run lookups.

pip install hvac on that Python, and your problem will resolve.

In my case, it returned the python for the local python env I was using.

I went the extra mile, modified the HVAC source code, and got a different interpreter being used by the local plugin (redacted)

/home/.../project_root/env/bin/ansible-playbook            

and it worked.

Related