# Issue with extra variables in 1.5.4

**URL:** <https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980>\
**Category:** Ansible Project\
**Created:** [April 9, 2014, 3:50pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980 "2014-04-09T15:50:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_Gargan](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Stephen\_Gargan](https://forum.ansible.com/u/Stephen_Gargan)\
**Post date:** [April 9, 2014, 3:50pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/1 "2014-04-09T15:50:39Z")

</div>

I’m seeing an issue with variable substitution between versions 1.5.3 and 1.5.4.

I have an include file that I use to create vm instances, create\_instance.yml and a playbook create\_cluster.yml that I use to spin up all the instances for the cluster in one go. I have variables in my group\_vars that I use to configure the cluster e.g. the cluster\_name and when I spin up a new cluster I usually override these using the extras vars switch -e

the create\_cluster looks something like the following

- hosts: localhost  
connection: local  
gather\_facts: False

tasks:

- {include: create\_instance.yml,  
tags: {  
hostname: ‘blah\_server1’,  
ansible\_groups: [“{{cluster\_name}}”, ‘blah-servers’],  
cluster\_name: “{{cluster\_name}}”  
}  
}

create\_instance.yml looks like

- debug: msg="creating instance for cluster ‘{{ cluster\_name }}’ ‘{{tags}}’ "

group\_vars/all

cluster\_name: dev

For instance to spin up a new ‘qa’ cluster, I would issue

ansible-playbook -i hosts create\_cluster.yml -e cluster\_name=qa

Up until recently this would correctly override the cluster\_name variable as expected and produce the output below. (Specifically notice how the cluster\_name is set to qa in the debug message)

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [debug msg="creating instance for cluster ‘qa’ ‘{‘cluster\_name’: u’qa’, ‘hostname’: ‘blah\_server1’, ‘ansible\_groups’: [u’qa’, ‘blah-servers’]}’ "] \*\*\*  
ok: [127.0.0.1] =\> {  
“item”: “”,  
“msg”: "creating instance for cluster ‘qa’ ‘{‘cluster\_name’: u’qa’, ‘hostname’: ‘blah\_server1’, ‘ansible\_groups’: [u’qa’, ‘blah-servers’]}’ "  
}

Between 1.5.3 and 1.5.4 this behavior has changed, running it with 1.5.4 produces.

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [debug msg="creating instance for cluster ‘qa’ ‘{‘cluster\_name’: u’qa’, ‘hostname’: ‘blah\_server1’, ‘ansible\_groups’: [u’qa’, ‘blah-servers’]}’ "] \*\*\*  
ok: [127.0.0.1] =\> {  
“item”: “”,  
“msg”: "creating instance for cluster ‘qa’ ‘{‘cluster\_name’: u’dev’, ‘hostname’: ‘blah\_server1’, ‘ansible\_groups’: [u’dev’, ‘blah-servers’]}’ "  
}

Notice how the variable is correctly substituted in the task listing, but in the msg it is not overridden correctly at all and is still ‘dev’. This causes me to spin up instances into the wrong cluster and in other playbooks that configure the cluster it applies changes to incorrect machines.

The changes between 1.5.3 and 1.5.4 are very limited, I think its related to the split from SETUP\_CACHE into VARS\_CACHE, but I’ve not tracked it down yet. Anyone any insight into what might have happened?

A gist of the files can be found here

[https://gist.github.com/10285167](https://gist.github.com/10285167)

Thanks,

Steve.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 15, 2014, 8:41pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/2 "2014-04-15T20:41:18Z")

</div>

This looks to be because the system is able to “early resolve” the variable cluster\_name and it tries to do so too soon.

Can you make sure there is a bug filed on this in github?

Thank you!

---

<div class="post-metadata">

**Author:** ![Garrett\_Plasky](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Garrett\_Plasky](https://forum.ansible.com/u/Garrett_Plasky)\
**Post date:** [April 15, 2014, 10:44pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/3 "2014-04-15T22:44:51Z")

</div>

This appears to be the same issue as [https://github.com/ansible/ansible/issues/6677](https://github.com/ansible/ansible/issues/6677) which has ben fixed and should roll out with 1.6.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 15, 2014, 10:53pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/4 "2014-04-15T22:53:45Z")

</div>

Excellent. Sounded a bit familiar 🙂

---

<div class="post-metadata">

**Author:** ![Stephen\_Gargan](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Stephen\_Gargan](https://forum.ansible.com/u/Stephen_Gargan)\
**Post date:** [May 28, 2014, 9:33pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/5 "2014-05-28T21:33:27Z")

</div>

Hi,

I’ve finally had a chance to circle back around to verifying this is fixed and I noticed there was a bug in my gist. The all file should be in a group\_vars folder. When I move the vars file there the failure returns. It seems as you suspected that the cluster\_name from there is still being resolved too early, even with the fix for [https://github.com/ansible/ansible/issues/6677](https://github.com/ansible/ansible/issues/6677)

I’ve tracked it down to the following, \_executor\_internal is run in the runner module to execute the debug task, this calls on 564

module\_vars = template.template(self.basedir, self.module\_vars, module\_vars\_inject)

and the module vars sent in for templating are only the vars extracted from the hosts file, not the combined set

{‘cluster\_name’: ‘dev’, ‘inventory\_hostname’: ‘127.0.0.1’, ‘inventory\_hostname\_short’: ‘127’, ‘ansible\_python\_interpreter’: ‘/usr/local/bin/python’, ‘group\_names’: [‘localhost’]}

So even though the task output shows the variables resolved and templated correctly using the combined set

TASK: [debug msg="creating instance for cluster ‘stage’ ‘{‘cluster\_name’: u’stage’, ‘hostname’: ‘blah\_server1’, ‘ansible\_groups’: [u’stage’, ‘blah-servers’]}’ "] \*\*\*

the execution is using the incomplete set and resolves to

ok: [127.0.0.1] =\> {  
“item”: “”,  
“msg”: "creating instance for cluster ‘stage’ ‘{‘cluster\_name’: u’dev’, ‘hostname’: ‘blah\_server1’, ‘ansible\_groups’: [u’dev’, ‘blah-servers’]}’ "  
}

I’m going to see if I can’t get it to pass the combined set in here, if I can I’ll create a patch. Should I open a bug for this?

regards,

Steve.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 29, 2014, 6:04pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/6 "2014-05-29T18:04:41Z")

</div>

Per the above, 1.6 is already released. If you have a bug in 1.6 please file it and include the most minimal reproducer possible along with it.

We will not be updating the 1.5.X series.

---

<div class="post-metadata">

**Author:** ![Stephen\_Gargan](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Stephen\_Gargan](https://forum.ansible.com/u/Stephen_Gargan)\
**Post date:** [May 29, 2014, 6:20pm UTC](https://forum.ansible.com/t/issue-with-extra-variables-in-1-5-4/14980/7 "2014-05-29T18:20:04Z")

</div>

Didn’t realize 1.6 was gold, nice work. I’d pulled a day or so ago so the issue was still there then. I’ve tracked down what the issue is and have a patch. If its still there in the 1.6 branch I’ll issue a patch.

thanks.

Steve.
