you can use hostvars to access it through a host that belongs to the other group

hostvars['hostname']['varname']

if you don't know the host you can use the groups['groupname'] list to get one

hostvars[groups['groupname'][0]]['varname']

^ this looksup the var from the first host in the group, you can also
use |random or other indecies if you know them.

On Mon, Nov 9, 2015 at 5:51 PM, Florin Andrei <[email protected]> wrote:
> I have several inventory files, where many groups are defined. For the big
> groups, I've defined variables in ./group_vars/${group_name}/main.yml
>
> For one role, which is typically executed only against two groups
> (specifically, against one host in each one of those two big groups), I need
> to "borrow" a variable defined in pretty much all other groups. How do I do
> that? How do I tell the role to use that variable, but with the value
> defined in another group?
>
> Of course, I could hardcode the values within that role, but then those
> values would be defined twice: once in this role, and then again as a group
> variable in all other groups. I want to avoid that.
>
> --
> 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/3d3188c5-5a77-48ac-bc51-136c7f425da2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Brian Coca

-- 
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/CAJ5XC8%3DHCEfO3fXAM2rwt1FU02xtk7RQGPGPrQ5a%2B0LSNSXD5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to