user1165419
user1165419

Reputation: 663

Ansible not picking up custom module

I'm having issues with Ansible picking up a module that I've added.

  1. The module is called 'passwordstore' https://github.com/morphje/ansible_pass_lookup/.
  2. I'm using Ansible 2.2
  3. In my playbook, I've added a 'library' folder and have added the contents of that GitHub directory to that folder. I've also tried uncommenting library = /usr/share/ansible/modules and adding the module files there and still doesn't get picked up.
  4. Have also tried setting environment variable to ANSIBLE_LIBRARY=/usr/share/ansible/modules

My Ansible playbook looks like this:

---

- name: example play
  hosts: all
  gather_facts: false

  tasks:
    - name: set password
      debug: msg="{{ lookup('passwordstore', 'files/test create=true')}}"

And when I run this I get this error;

ansible-playbook main.yml

PLAY [example play] ******************************************************

TASK [set password] ************************************************************
fatal: [backend.example.name]: FAILED! => {"failed": true, "msg": "lookup plugin (passwordstore) not found"}
fatal: [mastery.example.name]: FAILED! => {"failed": true, "msg": "lookup plugin (passwordstore) not found"}
        to retry, use: --limit @/etc/ansible/roles/test-role/main.retry

Any guidance on what I'm missing? It may just be the way in which I'm trying to add the custom module, but any guidance would be appreciated.

Upvotes: 0

Views: 4388

Answers (1)

techraf
techraf

Reputation: 68509

It's a lookup plugin (not a module), so it should go into a directory named lookup_plugins (not library).

Alternatively, add the path to the cloned repository in ansible.cfg using the lookup-plugins setting.

Upvotes: 4

Related Questions