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

**URL:** <https://forum.ansible.com/t/is-there-a-way-to-register-a-variable-with-a-hash-key/21601>\
**Category:** Ansible Project\
**Created:** [May 29, 2016, 11:46pm UTC](https://forum.ansible.com/t/is-there-a-way-to-register-a-variable-with-a-hash-key/21601 "2016-05-29T23:46:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Leo\_Huetter](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Leo\_Huetter](https://forum.ansible.com/u/John_Leo_Huetter)\
**Post date:** [May 29, 2016, 11:46pm UTC](https://forum.ansible.com/t/is-there-a-way-to-register-a-variable-with-a-hash-key/21601/1 "2016-05-29T23:46:44Z")

</div>

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 }}”
