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/8984b829-bccc-47d6-b389-ac3e2faf4b95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to