On 30.11.2016 10:08, Pieter Voet wrote:
True. And thanks for contributing.
I knew this.  I think I oversimplified my testcase...   Thing is, our
inventory has many groups, where hosts can be member
of multiple groups..  Here's a modified testcase :


groupall = { host_a, host_b, host_c }

    group1 = { host_a }
    group2 = { host_b, host_c }


---
- hosts: group1
  tasks:
  - name: get the variable value
    whatever_module: arg=arg_a
    register: result

- hosts: group2
  tasks:
  - debug: var="{{result}}"

The playbook is started with the '--limit groupall'  argument.


Now, because of the groups, the second play cannot lookup 'host_a' in the
hostvars, since it has no knowledge
about the hosts in 'group1'...

Any ideas ?

Knowledge of members in group1 you find with groups['group1']

So this should work.

hostvars[groups['group1'][0]]['result']

--
Kai Stian Olstad

--
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/6a91aa927e914a1246cd5b2c8937f757%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to