# How to use the ansible\_env.ProgramFiles(x86) variable

**URL:** <https://forum.ansible.com/t/how-to-use-the-ansible-env-programfiles-x86-variable/24153>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 6, 2017, 7:45am UTC](https://forum.ansible.com/t/how-to-use-the-ansible-env-programfiles-x86-variable/24153 "2017-04-06T07:45:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noel\_Verhoeven](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@Noel\_Verhoeven](https://forum.ansible.com/u/Noel_Verhoeven)\
**Post date:** [April 6, 2017, 7:45am UTC](https://forum.ansible.com/t/how-to-use-the-ansible-env-programfiles-x86-variable/24153/1 "2017-04-06T07:45:54Z")

</div>

I’ve been trying to use this variable (host is a windows 2K12 machine), but I guess the parsers trip over the brackets/parentheses in the name in the last task … Previous tasks all work correct. Should be better to rename the variable to something without brackets

The test playbook is:

- hosts: Myserver  
gather\_facts: true

pre\_tasks:

- name: env  
debug:  
var: ansible.env

- name: ProgramFiles  
debug:  
var: ansible\_env.ProgramFiles

- name: ProgramFiles  
debug:  
var: ansible\_env.ProgramFiles(x86)

ansible fails on the last task with:

TASK [ProgramFiles] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

**task path: /home/noel/work/ivv-test/ansible/test.yml:14**

An exception occurred during task execution. The full traceback is:

Traceback (most recent call last):

File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 126, in run

res = self.\_execute()

File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 502, in \_execute

result = self.\_handler.run(task\_vars=variables)

File “/usr/lib/python2.7/site-packages/ansible/plugins/action/debug.py”, line 57, in run

results = self.\_templar.template(self.\_task.args[‘var’], convert\_bare=True, fail\_on\_undefined=True, bare\_deprecated=False)

File “/usr/lib/python2.7/site-packages/ansible/template/ **init**.py”, line 383, in template

disable\_lookups=disable\_lookups,

File “/usr/lib/python2.7/site-packages/ansible/template/ **init**.py”, line 583, in do\_template

res = j2\_concat(rf)

File “”, line 9, in root

File “/usr/lib/python2.7/site-packages/jinja2/runtime.py”, line 177, in call

fn = \_\_obj. **call**

AttributeError: ‘AnsibleUnsafeText’ object has no attribute ‘ **call** ’

fatal: [chat01]: FAILED! =\> {

“failed”: true,

“msg”: “Unexpected failure during module execution.”,

“stdout”: “”

}

to retry, use: --limit @./retry-files/test.retry

Regards, Noel

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 6, 2017, 1:33pm UTC](https://forum.ansible.com/t/how-to-use-the-ansible-env-programfiles-x86-variable/24153/2 "2017-04-06T13:33:58Z")

</div>

Use the other way of specifying a python hash key, like this:

`

- hosts: Myserver  
gather\_facts: true

pre\_tasks:

- name: env  
debug:  
var: ansible.env

- name: ProgramFiles  
debug:  
var: ansible\_env[‘ProgramFiles’]

- name: ProgramFiles(x86)  
debug:  
var: ansible\_env[‘ProgramFiles(x86)’]  
`

As you can see it will work for either.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Noel\_Verhoeven](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@Noel\_Verhoeven](https://forum.ansible.com/u/Noel_Verhoeven)\
**Post date:** [April 6, 2017, 2:35pm UTC](https://forum.ansible.com/t/how-to-use-the-ansible-env-programfiles-x86-variable/24153/3 "2017-04-06T14:35:10Z")

</div>

Thanks, that works.
