Hi all,
I've been looking into this for some time now, and I think I definitely can use some help here.
What I want is to set a variable from a task specific to one host from a group, with a value that is set dynamically by the task outcome.
Then next, I want to use this variable by another play, with more hosts from that same group.
e.g. :
group = { host_a, host_b, host_c }
---
- hosts: host_a
tasks:
- name: get the variable value
whatever_module: arg=arg_a
register: result
- hosts: all
tasks:
- debug: var="{{result}}"
I know there already has been some discussion about this... Hopefully I didn't miss something in previous posts..
I can't use 'set_fact' in the first play, since that will only set the fact for the hosts specified, i.e. 'host_a'.
Trying to write some action plugin to 'set a global variable' failed, because I stumbled upon the point that
now ( V2 ) a 'fork()' is used, hence rendering all references in the plugin immutable..
( was able to get to 'self._task.get_variable_manager()' which returned a reference to the Plays' VariableManager,
but setting any value in it's '_extra_vars' was lost after the 'os._exit()' in 'forking.py' 'Popen' class..
I think this is caused by design : Play information should be on a 'need to know' base, and also a Play should not be
able to change a value set as an 'extra_var'.
Then I found a post from august where Matt Davis said : 'There are still ways to root around in inventory from an action plugin under 2.x (eg, self._templar._available_variables), but the objects are effectively immutable...' ..
So, the question I want to ask here is : is it / will it be possible to pass values from plays with certain hosts back to different hosts in other plays ?
Thanks in advance, and apologies if I could have found the answer myself...
have a nice day !
pieter.