debug msg ignore other results.

11 views
Skip to first unread message

Jegan A

unread,
Jan 14, 2020, 12:48:31 AM1/14/20
to Ansible Project
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"
}


James Cassell

unread,
Jan 14, 2020, 4:33:12 AM1/14/20
to Ansible List
loop_control:
label: "{{ item.invocation.module_args.volume_id }}"

Or similar.

V/r,
James Cassell

Jegan A

unread,
Jan 14, 2020, 7:36:30 AM1/14/20
to Ansible Project
Thanks a lot. It is working for me.

alicia

unread,
Jan 14, 2020, 3:12:43 PM1/14/20
to ansible...@googlegroups.com
For more details, see the section on “Adding controls to loops” here:




--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f46e6744-4e77-4f23-a5a0-51997c98932e%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages