On Wed, 18 Mar 2020 13:53:09 +0100
Michael Ströder <[email protected]> wrote:

> I'd like to override a default for
> var_b defined in roles/role_b/defaults/main.yml
> 
> with a value of
> 
> var_a defined in roles/role_a/defaults/main.yml
> 
> Is this possible?

If you import the roles try (not tested)

  shell> cat roles/role_b/defaults/main.yml
  var_b: "{{ ('role_a' in ansible_role_names)|
             ternary(var_a, 'var_b_default_in_role_b') }}"

> Can I reference role vars?

Yes. Simply reference the variable. For example

  - debug:
      var: var_b

> Or is this rather a use-case of include_role?

Include role is more complex because the variables of the included role might
be available in the playbook after the include. See attribute "public"
https://docs.ansible.com/ansible/latest/modules/include_role_module.html#parameter-public

HTH,

        -vlado

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200318143900.548f12d9%40gmail.com.

Attachment: pgpURvA8oS2uX.pgp
Description: OpenPGP digital signature

Reply via email to