module_defaults not working

15 views
Skip to first unread message

Punit Jain

unread,
Jan 12, 2020, 8:20:24 AM1/12/20
to ansible...@googlegroups.com
Hi,

I have a playbook which imports custom role and passes required attributes. My requirement is to pass only required attributes and role specify remaining. below is explained in detail.

playbook
------------

---
- hosts: remote
  gather_facts: yes
  tasks:
    - import_role: {name: xaas}
    - name: call action
      xaasaction:
        id: "{{id}}"
        action: "{{action}}"
      register: output

    - name: print values
      debug: var=output

the role task as below:
---
# tasks file for testrole
- xaasaction:
  module_defaults:
    xaasaction:
      username: "{{username}}"
      password: "{{password}}"

username and password are picked from vars/main.yml inside the role


The issue is module_defaults doesnot take effect.
output is

"invocation": {
      "module_args":
              "id": 12,
              "action": create,
              "username": null,
              "password": null

Any advice how to make it work so that module_defaults values are passed to the module along with other arguments?

Thanks and Regards,
Punit


Reply all
Reply to author
Forward
0 new messages