Hi Ananda, Registered variables are available in the global scope and can be accessed by any roles within the same play. However, I would recommend against this as it could make your roles very fragile and very tightly coupled, meaning their reusability would be limited. It sounds like this functionality should all be in a single role rather than split into multiples.
Hope that helps! On Mon, Dec 1, 2014 at 1:41 PM, Ananda Debnath <[email protected]> wrote: > *ping* - any advice on passing variables from one role to another? > > On Tuesday, November 25, 2014 8:58:49 AM UTC-6, Ananda Debnath wrote: >> >> Hola, >> >> I have a playbook with multiple roles mapped to multiple vms. I'm >> registering a variable in the output of one of the tasks in role A and need >> to pass it to role B. Calling register or set_facts in the role A tasks >> file works as expected within role A, but this var doesn't seem to make it >> into the tasks listed in role B. I finally used hostvars['vmA']['myvar'] to >> access this variable from the tasks of role B. So I suspect I'm missing >> something about how vars are scoped and referenced. >> >> Is hostvars the recommended way to do this or am I missing something >> obvious? >> >> Thanks, >> Ananda > > -- > 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/7c26bcc7-4324-4549-a2b2-ba1f6825e9c5%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/7c26bcc7-4324-4549-a2b2-ba1f6825e9c5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CAMFyvFhmqb3wu84wYvTk8-t2%2BSJur1c_NL83a26c8sTcu7dQ3w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
