Hello Team,
I am iterating register result using debug and loop but it prints other variable result as well how to ignore that one while printing value which I want Below is the sample results. Cloud you please help me on this issues. I just want to print value of “item.invocation.module_args.volume_id” and ignore other results.
- debug:
msg: “{{ item.invocation.module_args.volume_id }}”
register: unused_block
with_items: “{{result_1.results}}”
when: item.volume_attachments | length == 0
debug result
TASK [debug] *********************************************************************************************************************
skipping: [localhost] => (item={‘failed’: False, ‘ansible_loop_var’: u’item’, u’volume_attachments’: [{u’chap_username’: None, u’time_created’: u’2019-12-26T09:38:51.785000+00:00’, u’is_read_only’: False, u’volume_id’: u’xxxxxxxxxxxx’, u’device’: None, u’xxxxxxxxxxx’, u’lifecycle_state’: u’ATTACHED’, u’availability_domain’: u’xxxxxxxxxx’, u’display_name’: u’volumeattachment20191226093851’, u’compartment_id’: u’xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’, u’port’: 3260, u’instance_id’: u’xxxxxxxxxxxxxxxxxxxxx’, u’iqn’: u’xxxxxxxxxxxxxxxxxxxxx’, u’is_pv_encryption_in_transit_enabled’: False, u’attachment_type’: u’iscsi’, u’chap_secret’: None, u’ipv4’: u’169.254.2.2’}], ‘item’: u’xxxxxxxxxxxxxxxxxxxxxxx’, u’invocation’: {u’module_args’: {u’auth_type’: u’api_key’, u’api_user_key_pass_phrase’: None, u’availability_domain’: None, u’display_name’: None, u’config_profile_name’: u’root’, u’compartment_id’: u’xxxxxxxxxxxxxxx’, u’region’: None, u’volume_id’: u’xxxxxxxxxxxxxxxxxxxxxxx’, u’instance_id’: None, u’tenancy’: None, u’api_user_key_file’: None, u’api_user_fingerprint’: None, u’api_user’: None,
u’config_file_location’: u’~/.oci/config’, u’volume_attachment_id’: None}}, ‘changed’: False, ‘ansible_facts’: {u’discovered_interpreter_python’: u’/usr/bin/python’}})
ok: [localhost] => (item={‘failed’: False, ‘ansible_loop_var’: u’item’, u’volume_attachments’: , ‘item’: u’xxxxxxxxxxxxxxxxxxxxxxxx’, u’invocation’: {u’module_args’: {u’auth_type’: u’api_key’, u’api_user_key_pass_phrase’: None, u’availability_domain’: None, u’display_name’: None, u’config_profile_name’: u’root’, u’compartment_id’: u’xxxxxxxxxxxxxxxxxxxxxxxxxx’, u’region’: None, u’volume_id’: u’xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’, u’instance_id’: None, u’tenancy’: None, u’api_user_key_file’: None, u’api_user_fingerprint’: None, u’api_user’: None, u’config_file_location’: u’~/.oci/config’, u’volume_attachment_id’: None}}, ‘changed’: False}) => {
“msg”: “xxxxxxxxxxxxxxxxxxxxxx”
}