OK, so I looked at Ansible's code, and I now know how to implement this.
I tried my modification locally and
it works fine. It basically adds a module that adds an 'extra_vars'
variable if it does not yet exist.
That way, any variable set on the commandline using the '--extra-vars'
OK, redefining my testcase then :
>
> groupall = { host_a, host_b, host_c }
>
group1 = { host_x, host_y, host_a, host_z }
group2 = { host_b, host_c }
>
> ---
> - hosts: group1
> tasks:
> - name: get the variable value
> whatever_module: arg=arg_a
> register: result
>
> -
On 30.11.2016 11:50, Pieter Voet wrote:
Hi Kai,
you said :
Knowledge of members in group1 you find with groups['group1']
hostvars[groups['group1'][0]]['result']
actually, the 'group1' group contains a lot of hosts.. There is no
quarantee
that the first entry in that array actually is the
Hi Kai,
you said :
> Knowledge of members in group1 you find with groups['group1']
> hostvars[groups['group1'][0]]['result']
actually, the 'group1' group contains a lot of hosts.. There is no
quarantee
that the first entry in that array actually is the host that applies to my
playbook.
--
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 }
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 = {