with_items calling role variables, doable??

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

   - "{{ 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.

Thanks it was wrong syntax for variable names now i am using {{ GE_COMMON_GZ }}

Is everything working now?

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

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