Petros Moisiadis
unread,May 15, 2014, 8:37:22 AM5/15/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Is there any way to change a global variable (e.g. defined in the vars
section of a playbook) in a task for the current playbook run?
The use case is that I want to start with a boolean variable set to
True, and then run a command over a set of hosts. If a command at _any_
of the hosts returns a specific value in stdout, I want to set the
global boolean variable to False. This 'control' boolean variable will
be checked later to decide where to run (or not run) some other tasks,
so what I want actually is to create a conditional based on output from
multiple tasks or multiple runs in a task loop . I know about the
'set_fact' module, but this works on a per-host basis, not on global
vars, so it does not help. Perhaps, I need a 'set_var' or 'set_global'
module or something like that. I can think of some hacky ways to
workaround my case (e.g. use a temporary file instead of a global var),
but I think changing the value of a global var at will in the course of
a playbook run should be something that Ansible should allow us to do.
Am I missing something here?