Is there a way to register a variable with a hash key?

Hello,

I run a command via looping in a “with_items” and registering the output into a hash with the item as a key.

However when I do this, I am having difficulty referencing the specific results when I try and key on “item” later.

I want to know which SID is unavailable (I only care if it tnspings, I will check actually logging in later).

Assume this_database_sid_list is an array of [‘db1’,‘db2’,‘db3’]

Playbook snippet:

  • name: Ensure all SIDS this app needs are available on each server
    command: “tnsping {{ item }}”

with_items: “{{ this_database_sid_list }}”

register: tnsping_results <— can I register with a key of item???

  • name: See results
    debug: msg=“Result is {{ tnsping_results.item.stdout }}” <— ??? how do I reference the results with the key of item?
    with_items: “{{ this_database_sid_list }}”