# with\_items calling role variables, doable??

**URL:** <https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956>\
**Category:** Ansible Project\
**Created:** [November 21, 2013, 2:37pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956 "2013-11-21T14:37:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [November 21, 2013, 2:37pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956/1 "2013-11-21T14:37:14Z")

</div>

Hi,

I am trying to use with\_items to call items that are role variables however it fails with the below error message, can you please let me know what I am doing wrong?

> TASK: [copy the files for Grid Engine installation] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> fatal: [tlcav117] =\> Traceback (most recent call last):
> 
> File “/root/ansible-release1.3.4/lib/ansible/runner/ **init**.py”, line 382, in \_executor
> 
> exec\_rc = self.\_executor\_internal(host, new\_stdin)
> 
> File “/root/ansible-release1.3.4/lib/ansible/runner/ **init**.py”, line 451, in \_executor\_internal
> 
> items\_terms = template.template(basedir, items\_terms, inject)
> 
> File “/root/ansible-release1.3.4/lib/ansible/utils/template.py”, line 328, in template
> 
> return [template(basedir, v, vars, lookup\_fatal, depth, expand\_lists, fail\_on\_undefined=fail\_on\_undefined) for v in varname]
> 
> File “/root/ansible-release1.3.4/lib/ansible/utils/template.py”, line 310, in template
> 
> varname = template\_from\_string(basedir, varname, vars, fail\_on\_undefined)
> 
> File “/root/ansible-release1.3.4/lib/ansible/utils/template.py”, line 512, in template\_from\_string
> 
> res = jinja2.utils.concat(t.root\_render\_func(t.new\_context(\_jinja2\_vars(basedir, vars, t.globals, fail\_on\_undefined), shared=True)))
> 
> File “”, line 11, in root
> 
> TypeError: unsupported operand type(s) for -: ‘StrictUndefined’ and ‘StrictUndefined’
> 
> FATAL: all hosts have already failed – aborting
> 
> * * *

,My defined role have the following task that cause the above error:

> - name: copy the files for Grid Engine installation
> 
> copy: src={{ item }} dest={{ ge\_root\_dir }} owner={{ ge\_user }}
> 
> with\_items:
> 
> - “{{ ge-common.tgz }}”
> 
> - “{{ ge-bin-lx-amd64.tgz }}”
> 
> - “{{ ge-arco.tgz }}”
> 
> The variables are defined under the roles/ge\_master/vars as follow:
> 
> - name: copy the files for Grid Engine installation
> 
> copy: src=“{{ item }}” dest={{ ge\_root\_dir }} owner={{ ge\_user }}
> 
> with\_items:
> 
> - “{{ ge-common.tgz }}”
> 
> - “{{ ge-bin-lx-amd64.tgz }}”
> 
> - “{{ ge-arco.tgz }}”

Thanks

Walid

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 21, 2013, 2:39pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956/2 "2013-11-21T14:39:13Z")

</div>

> &nbsp;&nbsp;&nbsp;- "{{ ge-common.tgz }}"

\>  
\> - "{{ ge-bin-lx-amd64.tgz }}"  
\>  
\> - "{{ ge-arco.tgz }}"

These don't seem like variables, so remove the {{ }} to turn them into regular strings.

---

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [November 21, 2013, 2:57pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956/3 "2013-11-21T14:57:53Z")

</div>

Thanks it was wrong syntax for variable names now i am using {{ GE\_COMMON\_GZ }}

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 21, 2013, 2:58pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956/4 "2013-11-21T14:58:55Z")

</div>

Is everything working now?

---

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [November 21, 2013, 6:18pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956/5 "2013-11-21T18:18:36Z")

</div>

Yes James, thank you for the hint. I still have some other issues i need to iron out, hopefully nothing serious.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 21, 2013, 6:46pm UTC](https://forum.ansible.com/t/with-items-calling-role-variables-doable/13956/6 "2013-11-21T18:46:42Z")

</div>

Good deal.

BTW, let me know what version of Ansible you are on, if that was 1.4 we can/should work to make that error message better.

Incidentally if those _were_ two lists of variables, you also don’t need the “{{ foo }}” for with items:

with\_items:

- base\_package\_list\_variable
- addon\_package\_list\_variable

etc
