Hi

I'm trying to nest roles using dependencies in order to reuse as much code 
as possible and get into trouble when trying to omit some parameters

My setup:

# roles/roleA/tasks/main.yml
---
- debug: msg="var var_rolea is set to {{ var_rolea|default('no idea') }}"

# roles/roleB/meta/main.yml
dependencies:
  - { role: roleA,
      var_rolea: "{{ var_roleb }}"
    }

# playbook
# play1, specify value
- hosts: localhost
  gather_facts: no
  roles:
    - role: roleB
      var_roleb: plop

# play2, omit value, let defaults apply
- hosts: localhost
  gather_facts: no
  roles:
    - role: roleB



I get a « fatal: [localhost] => One or more undefined variables: 
'var_roleb' is undefined » error in this case.

I tried several tricks into the roleB/meta/main.yml, such as:

   - var_rolea: "{{ var_roleb|default(omit) }}"
   - var_rolea: "{{ var_roleb|default(None) }}"
   
But so far, I haven't found a pretty way to do this.

Any Idea?

Regards,

Arnaud

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/db47dc91-d2dc-49eb-99a4-2f785bbbfd43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to