# Reloading updated group\_vars/all mid-playbook execution

**URL:** <https://forum.ansible.com/t/reloading-updated-group-vars-all-mid-playbook-execution/22707>\
**Category:** Ansible Project\
**Created:** [October 3, 2016, 6:31pm UTC](https://forum.ansible.com/t/reloading-updated-group-vars-all-mid-playbook-execution/22707 "2016-10-03T18:31:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Kindel](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Kindel](https://forum.ansible.com/u/Dave_Kindel)\
**Post date:** [October 3, 2016, 6:31pm UTC](https://forum.ansible.com/t/reloading-updated-group-vars-all-mid-playbook-execution/22707/1 "2016-10-03T18:31:36Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 3, 2016, 7:11pm UTC](https://forum.ansible.com/t/reloading-updated-group-vars-all-mid-playbook-execution/22707/2 "2016-10-03T19:11:10Z")

</div>

have you tried?:

- meta: refresh\_inventory

It should refresh not only the inventory but reload all inventory files (host/group\_vars included).

---

<div class="post-metadata">

**Author:** ![Dave\_Kindel](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Kindel](https://forum.ansible.com/u/Dave_Kindel)\
**Post date:** [October 3, 2016, 7:38pm UTC](https://forum.ansible.com/t/reloading-updated-group-vars-all-mid-playbook-execution/22707/3 "2016-10-03T19:38:40Z")

</div>

I did try that but it didn’t seem to work with the group\_vars/all file. I haven’t tried to see what exactly it did refresh, but it wasn’t this.

---

<div class="post-metadata">

**Author:** ![Dave\_Kindel](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Kindel](https://forum.ansible.com/u/Dave_Kindel)\
**Post date:** [October 3, 2016, 7:58pm UTC](https://forum.ansible.com/t/reloading-updated-group-vars-all-mid-playbook-execution/22707/4 "2016-10-03T19:58:58Z")

</div>

Another note that I just got through trying set\_fact with catting the group\_vars/all file and reading the output lines. This didn’t work either as set\_fact is just one lower precedence than include\_vars. If there’s another module like set\_fact, I can do this work around method as well but I haven’t seen/noticed anything.
