Nobody got any comments if and where to best report these errors? While my
original mail was more of a rant than a constructive topic, I still have
these errors when I try to put a variable in ignore_errors:
When I directly reference a variable:
ERROR: error while evaluating conditional: ansible_check_mode
>
When I use a jinja placeholder:
Traceback (most recent call last):
> File "/usr/bin/ansible-playbook", line 323, in <module>
> sys.exit(main(sys.argv[1:]))
> File "/usr/bin/ansible-playbook", line 263, in main
> pb.run()
> File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py",
> line 348, in run
> if not self._run_play(play):
> File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py",
> line 788, in _run_play
> if not self._run_task(play, task, False):
> File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py",
> line 493, in _run_task
> task.ignore_errors = utils.check_conditional(cond, play.basedir,
> task.module_vars, fail_on_undefined=C.DEFAULT_UNDEFINED_VAR_BEHAVIOR)
> File "/usr/lib/python2.6/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/lib/python2.6/site-packages/ansible/utils/template.py", line
> 121, in template
> varname = template_from_string(basedir, varname, templatevars,
> fail_on_undefined)
> File "/usr/lib/python2.6/site-packages/ansible/utils/template.py", line
> 368, in template_from_string
> res = jinja2.utils.concat(rf)
> File "<template>", line 8, in root
> File "/usr/lib/python2.6/site-packages/jinja2/runtime.py", line 485, in
> _fail_with_undefined_error
> raise self._undefined_exception(hint)
> jinja2.exceptions.UndefinedError: 'ansible_check_mode' is undefined
>
I have since worked around the problem like this but I hate this kind of
boilerplate:
---
> - hosts: all
> name: testing
> tasks:
> - name: print variable
> action: debug msg="Does variable exist [{{ ansible_check_mode
> }}]"
> - name: Make symlink
> action: file src="/ohwhat/hai" dest="/there/youare" state=link
> ignore_errors: True
> register: symlinkresult
> - name: Fail if symlink could not be created
> action: fail msg="Symlink could not be created"
> when: "{{ not ( ansible_check_mode) and (symlinkresult | failed)
> }}"
>
With best regards,
Albert
--
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/797001d6-a1c4-41e9-91d0-5dfd5b1eddda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.