hostvars behavior different version 1.9 ->2.1

We have a template to create ifcfg files with the following partial snippet: (second line commented out for test with 2.1)

HWADDR={{ ansible_wlp2s0.macaddress }}
{#HWADDR={{ hostvars[inventory_hostname][‘ansible_’ + xsce_wireless_lan_iface|trim][‘macaddress’] ]] #}

In ansible version 1.9 both HWADDR lines function. In version 2.1, I had to comment out the hostvars line to execute the template without error.

So the syntax has changed, or something. I tried setting gathering=implicit in ansible.conf, but it did not fix the problem

Does anyone have a new syntax that works in version 2.1

The error returned at the console was:

TASK [1-prep : WiFi enslaving wlp2s0 to Bridge] ********************************
fatal: [127.0.0.1]: FAILED! => {“changed”: false, “failed”: true, “msg”: “AnsibleUndefinedVariable: ‘dict object’ has no attribute u’ansible_wlp2s0’”}

yet indeed ansible_wlp2s0 is defined when I do: “ansible -m setup localhost”

We have a template to create ifcfg files with the following partial
snippet: (second line commented out for test with 2.1)

HWADDR={{ ansible_wlp2s0.macaddress }}
{#HWADDR={{ hostvars[inventory_hostname]['ansible_' +
xsce_wireless_lan_iface|trim]['macaddress'] ]] #}

You have two square brackets at the end where it should be two curly brackets.

In ansible version 1.9 both HWADDR lines function. In version 2.1, I had to
comment out the hostvars line to execute the template without error.

So the syntax has changed, or something. I tried setting
gathering=implicit in ansible.conf, but it did not fix the problem

Does anyone have a new syntax that works in version 2.1

The syntax hasn't changed.