[ansible-project] ignore -has no attribute

2020-01-23 Thread Jegan A
Hello Team,

   I am parsing register value using debug and using when condition to 
print particular matching value. While doing that am getting below error. 
some of the register value doesn't have "volume_attachments" variable due 
to that the when condition is failing. I want to ignore this error how can 
I do it. Could you please help me on this. Thanks in advance.
  
fatal: [localhost]: FAILED! => {"msg": "The conditional check 
'item.volume_attachments | length == 0' failed. The error was: error while 
evaluating conditional (item.volume_attachments | length == 0): 'dict 
object' has no attribute 'volume_attachments'\n\nThe error appears to be in 
'/var/lib/home/s': line 33, column 7, but may\nbe elsewhere in the file 
depending on the exact syntax problem.\n\nThe offending line appears to 
be:\n\n\n- debug:\n  ^ here\n"}


Regards,
Jegan A

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b7353ab1-5a43-4d6d-a510-21d3dba61e1d%40googlegroups.com.


Re: [ansible-project] ignore -has no attribute

2020-01-23 Thread Martin Krizek
Use "default" filter:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#defaulting-undefined-variables

Example:
- hosts: localhost
  gather_facts: no
  vars:
d:
  key: value
  tasks:
- debug:
msg: "{{ d.missing_attr | default('default_value') }}"

On Thu, Jan 23, 2020 at 11:19 AM Jegan A  wrote:
>
> Hello Team,
>
>I am parsing register value using debug and using when condition to print 
> particular matching value. While doing that am getting below error. some of 
> the register value doesn't have "volume_attachments" variable due to that the 
> when condition is failing. I want to ignore this error how can I do it. Could 
> you please help me on this. Thanks in advance.
>
> fatal: [localhost]: FAILED! => {"msg": "The conditional check 
> 'item.volume_attachments | length == 0' failed. The error was: error while 
> evaluating conditional (item.volume_attachments | length == 0): 'dict object' 
> has no attribute 'volume_attachments'\n\nThe error appears to be in 
> '/var/lib/home/s': line 33, column 7, but may\nbe elsewhere in the file 
> depending on the exact syntax problem.\n\nThe offending line appears to 
> be:\n\n\n- debug:\n  ^ here\n"}
>
>
> Regards,
> Jegan A
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/b7353ab1-5a43-4d6d-a510-21d3dba61e1d%40googlegroups.com.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CADDq2ENXsqTFiVEmCybYAtaYztCSZQNL1rUsVLHLMP%3Dw4EHvcw%40mail.gmail.com.