I've been struggling with this concept for a bit now and thought I had a 
solution but was unfortunately mistaken.

During a system upgrade scenario, in a lower version, we might have an 
ansible group_vars/all file file with 3 variables.  In a higher version, we 
might add another variable to that file.  Right now, I've done a merge, 
just copying the new variable over to the old file (for certain reasons, I 
couldn't do a straight up file copy).  After this, though, I need to reload 
the group_vars/all file to capture that 4th variable.  I tried include_vars 
but the variable precedence is way too high to effectively use.  That is, 
if we include a playbook as follows as follows, the variable will never be 
read as you'd expect/hope:

- include: sub_playbook.yml new_var=value

If we run "include_vars" on group_vars/all where new_var is set as a 
default value of other_value, inside sub_playbook.yml, a debug of new_var 
will print "other_value" when we'd want "value."  However, it we do the 
merge in one playbook execution and then use the variable in the another 
one, the variable precedence is as we'd expect.  This is all noted in the 
documentation but isn't what we really need.  Is there any way to "reload" 
the group_vars/all file without include_vars or at the very least, with a 
lower precedence where something like this will be feasible?  I have also 
looked a the idea of just grepping for the new key-value pairs we're adding 
to group_vars/all but then we run into the issue of reaching for variables 
defined across hosts and that might not be the best idea, though it is an 
option.  

Thanks for any help!

-- 
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/d0358cfd-c673-4a0e-9213-df36d2b0047b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to