I need to do something like this in a role, and I use an endpoint for some 
of the items in the hash I feed it

  shell: dosomething.sh {{ item.endpoint }}
  when: "{{ item.endpoint }} is defined"
  with_items: {{ myhash }}

myhash:
  - { version: '{{ cqrs_version }}' }
  - { version: '{{ staging_version }}', endpoint: 
'http://localhost:8080/staging' }

It breaks as follows:

TASK: [gavdeploy | wait for endpoints to become available] 
********************
fatal: [ststxdapbe02] => Traceback (most recent call last):
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py",
 
line 586, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py",
 
line 815, in _executor_internal
    complex_args=complex_args
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/lib/python2.7/site-packages/ansible/runner/__init__.py",
 
line 869, in _executor_internal_inner
    if not utils.check_conditional(cond, self.basedir, inject, 
fail_on_undefined=self.error_on_undefined_vars):
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/lib/python2.7/site-packages/ansible/utils/__init__.py",
 
line 265, in check_conditional
    conditional = template.template(basedir, conditional, inject, 
fail_on_undefined=fail_on_undefined)
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/lib/python2.7/site-packages/ansible/utils/template.py",
 
line 122, in template
    varname = template_from_string(basedir, varname, templatevars, 
fail_on_undefined)
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/lib/python2.7/site-packages/ansible/utils/template.py",
 
line 371, in template_from_string
    res = jinja2.utils.concat(rf)
  File "<template>", line 8, in root
  File 
"/usr/local/Cellar/ansible/1.9.3/libexec/vendor/lib/python2.7/site-packages/jinja2/runtime.py",
 
line 489, in _fail_with_undefined_error
    raise self._undefined_exception(hint)
UndefinedError: 'dict object' has no attribute 'endpoint'

FATAL: all hosts have already failed -- aborting

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/741a548e-1b8d-4866-8331-299bb00c5306%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to