Try to remove the * from [*] and the square brackets from stdout ( change 
'stdout[]' becomes 'stdout' ). This will give you all of list of stdout 
strings. If you the individual lines of stdout then use stdout_lines.

  set_fact:
      pod_name: "{{ pods_info.results | json_query('[].stdout')  }}"

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Jan 17, 2023, at 12:22 AM, Shivani Arora <[email protected]> wrote:

Thanks for replying.

This is how I'm passing the variables -


ansible-playbook <playbook-name> --extra-vars 
"{'services_to_upgrade':{'hedwig':'1.0.9-63','venus':'1.0.11-2198'}}"

On Tuesday, January 17, 2023 at 1:44:22 AM UTC+5:30 [email protected] wrote:
Impossible without knowing what your variables look like. Provide those and we 
may be able to help

On Mon, 16 Jan 2023 at 19:35, Shivani Arora <[email protected]> wrote:
Hi All,

I need help with writing an ansible playbook, where it loops over a few pods 
and checks if any pod is not running, does a describe on it, and prints the 
events (we get when we describe pods).

I'm stuck on the 2nd task here, where I can fetch 'stdout' but cannot filter 
the pod name from stdout. Please suggest how I can implement this.

I'm passing services_to_upgrade as an argument while running the playbook.

- name: Get pod information
  command: "kubectl get pods -l app={{ item }} -o json"
  register: pods_info
  with_items: "{{ services_to_upgrade.keys() }}"

- name: Print pod info
  set_fact:
      pod_name: "{{ pods_info.results| json_query('[*].stdout[]')  }}"

I am looking forward to any suggestions.

Thanks



--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/053ec500-6af3-478b-9d57-cafa9020471cn%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F053ec500-6af3-478b-9d57-cafa9020471cn%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C97ded5880caa4ed7a0de08daf84ac77a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638095297325479848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=s47R3Skhzykezh4RSvdLLqX4MBw67nMnscdHXHOTM7o%3D&reserved=0>.
--
Sent from Gmail Mobile

--
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 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6b27b9ad-4339-414a-8f09-7277a132bdfan%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F6b27b9ad-4339-414a-8f09-7277a132bdfan%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C97ded5880caa4ed7a0de08daf84ac77a%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638095297325479848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XvWA%2BHDoTlyPmz93%2B0VkvMRrxJnABZ6dMqn38dPOimc%3D&reserved=0>.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7BFDAA0B-BE1B-4C05-B0E8-674047294E0A%40nist.gov.

Reply via email to