module_defaults not working

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

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

Your module_defaults in the role is not valid here. It only takes effect for the task where it is specified. You could add it to the play above to make it effective for this task.

V/r,
James Cassell

Hi James,

My role is being used by multiple other roles and playbooks. This would mean it will require every playbook and role accessing this module, to pass username and password fields which I think should be abstracted and should be taken care by something like module_defaults and let the playbook and role only pass required attributes which change. Thoughts ?

Regards,
Punit