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

60 views
Skip to first unread message

johhue

unread,
May 29, 2016, 7:46:44 PM5/29/16
to Ansible Project
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 }}"
Reply all
Reply to author
Forward
0 new messages