Hi Yasir,
Have you read
through: http://docs.ansible.com/playbooks_error_handling.html ?
Ignore_errors is taking yes or no, because simply put there isn't any other
answer possible to "Do you want me to ignore the errors?" yes/no. You are
answering with "Mooo" and the system doesnt speak cowish, yet
I'm interested in knowing why do you want to let ignore_errors take a
variable?
Regards,
Mark
On Monday, October 6, 2014 7:22:18 PM UTC+2, Yasir Saleem wrote:
>
> Hi,
> I was trying to use ignore_errors to take a variable, but it fails.
>
> Here is example play for ignore error not working:
>
> - hosts: jump
> remote_user: deploy
> gather_facts: yes
> tasks:
> - set_fact: test_err=yes
> - debug: var=test_err
> ignore_errors: "{{ test_err }}"
>
> output was:
>
> #############
> PLAY [jump]
> *******************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [qa10-jump1]
>
> TASK: [set_fact test_err=yes]
> *************************************************
> ok: [qa10-jump1]
>
> TASK: [debug var=test_err]
> ****************************************************
> Traceback (most recent call last):
> File "/usr/local/bin/ansible-playbook", line 309, in <module>
> sys.exit(main(sys.argv[1:]))
> File "/usr/local/bin/ansible-playbook", line 249, in main
> pb.run()
> File "/Library/Python/2.7/site-packages/ansible/playbook/__init__.py",
> line 339, in run
> if not self._run_play(play):
> File "/Library/Python/2.7/site-packages/ansible/playbook/__init__.py",
> line 695, in _run_play
> if not self._run_task(play, task, False):
> File "/Library/Python/2.7/site-packages/ansible/playbook/__init__.py",
> line 468, in _run_task
> task.ignore_errors = utils.check_conditional(cond , play.basedir,
> task.module_vars, fail_on_undefined=C.DEFAULT_UNDEFINED_VAR_BEHAVIOR)
> File "/Library/Python/2.7/site-packages/ansible/utils/__init__.py", line
> 254, in check_conditional
> conditional = template.template(basedir, conditional, inject,
> fail_on_undefined=fail_on_undefined)
> File "/Library/Python/2.7/site-packages/ansible/utils/template.py", line
> 115, in template
> varname = template_from_string(basedir, varname, vars,
> fail_on_undefined)
> File "/Library/Python/2.7/site-packages/ansible/utils/template.py", line
> 357, in template_from_string
> res = jinja2.utils.concat(rf)
> File "<template>", line 8, in root
> File "/Library/Python/2.7/site-packages/jinja2/runtime.py", line 485, in
> _fail_with_undefined_error
> raise self._undefined_exception(hint)
> jinja2.exceptions.UndefinedError: 'test_err' is undefined
>
> ##################
>
> When I use a static value, 'yes' it works:
>
> - hosts: jump
> remote_user: deploy
> gather_facts: yes
> tasks:
> - set_fact: test_err=yes
> - debug: var=test_err
> ignore_errors: yes
>
> output was:
>
> ###########
> PLAY [jump]
> *******************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [qa10-jump1]
>
> TASK: [set_fact test_err=yes]
> *************************************************
> ok: [qa10-jump1]
>
> TASK: [debug var=test_err]
> ****************************************************
> ok: [qa10-jump1] => {
> "test_err": "yes"
> }
>
> PLAY RECAP
> ********************************************************************
> qa10-jump1 : ok=3 changed=0 unreachable=0 failed=0
> ######
>
> Isn't this a bug?
>
> I am using ansible 1.7.1 release
>
> Thanks,
> Yasir.
>
--
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/ba187ef4-3db9-46fd-91af-8ce25d6ba45f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.