Response' object has no attribute '__getitem__ while running the lookup plugin 'hashi_vault'

10 views
Skip to first unread message

Asmitha j.s

unread,
May 20, 2020, 6:02:15 AM5/20/20
to Ansible Project
I'm using hashi_vault to retrieve secrets from HashiCorp’s vault in ansible playbook.

  - name: Return all secrets from a path
    set_fact
:
       vault_result
: "{{ lookup('hashi_vault', 'secret=secret/key:value token=token url=https://vaultaddress/ui/vault/secrets/secret/list/folder/subfolder/environment/')}}"


    tags
:
       
- vault

 
command i'm using to run pl is ansible-playbook -v plybook.yml --tags vault 

I'm getting following error:
fatal: [server_addr]: FAILED! => {
   
"msg": "An unhandled exception occurred while running the lookup plugin 'hashi_vault'. Error was a <type 'exceptions.TypeError'>, original message: 'Response' object has no attribute '__getitem__'"
}


My python version is Python 2.7.5
My pip versin is pip 20.1
My Ansible version is
 ansible
2.9.3
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = [u'/home/asmithas/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python
module location = /usr/lib/python2.7/site-packages/ansible
  executable location
= /usr/bin/ansible
  python version
= 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]


vinoth kumar

unread,
May 20, 2020, 2:30:05 PM5/20/20
to ansible...@googlegroups.com

Have you installed pip hashi vault module . I think you have to install the pip module for this connection. Check in hashi vault module page in official ansible document . In first few line you can see the requirements. Fix that it will work .

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a0a2b672-80ad-4066-8be4-7218788d2611%40googlegroups.com.

Asmitha j.s

unread,
May 21, 2020, 3:27:46 AM5/21/20
to Ansible Project
I'm refering to https://docs.ansible.com/ansible/latest/plugins/lookup/hashi_vault.html document. It requires hvac (python library). and i have already installed it. Im trying connect by github token.


On Thursday, May 21, 2020 at 12:00:05 AM UTC+5:30, vinoth kumar wrote:
Have you installed pip hashi vault module . I think you have to install the pip module for this connection. Check in hashi vault module page in official ansible document . In first few line you can see the requirements. Fix that it will work .

On Wed 20. May 2020 at 12:02, Asmitha j.s <asmi...@gmail.com> wrote:
I'm using hashi_vault to retrieve secrets from HashiCorp’s vault in ansible playbook.

  - name: Return all secrets from a path
    set_fact
:
       vault_result
: "{{ lookup('hashi_vault', 'secret=secret/key:value token=token url=https://vaultaddress/ui/vault/secrets/secret/list/folder/subfolder/environment/')}}"


    tags
:
       
- vault

 
command i'm using to run pl is ansible-playbook -v plybook.yml --tags vault 

I'm getting following error:
fatal: [server_addr]: FAILED! => {
   
"msg": "An unhandled exception occurred while running the lookup plugin 'hashi_vault'. Error was a <type 'exceptions.TypeError'>, original message: 'Response' object has no attribute '__getitem__'"
}


My python version is Python 2.7.5
My pip versin is pip 20.1
My Ansible version is
 ansible
2.9.3
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = [u'/home/asmithas/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python
module location = /usr/lib/python2.7/site-packages/ansible
  executable location
= /usr/bin/ansible
  python version
= 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages