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
Thanks,
Steve.