-1

instance_tags.stdout output would look like

enter image description here

Expected output of fallowing snippet is App Server-Development

- name: get instance tags
  win_shell: aws ec2 --region us-east-1 describe-tags \ --filters "Name=resource-id,Values={{instance_id}}"
  register: instance_tags


- name: echo instance tags
  debug:
    msg: "{{instance_tags.stdout | json_query('Tags[?Key==''AMSPatchGroup''].Value')}}"

But Actual Output is

enter image description here

  • 1
    Can you share output of the following debug: msg: "{{instance_tags.stdout.Tags[0] }}" – Uttam Aug 23 '20 at 12:14
  • 1
    Please don't post code snippets as images; it is explicitly mentioned in the [how to ask](https://stackoverflow.com/help/how-to-ask) page – mdaniel Aug 23 '20 at 18:15

1 Answers1

0

You at least want instance_tags.stdout | from_json | ... since .stdout is a string, not an actual structure

One can see this behavior with a simple experiment showing {{ '{"a":"b"}' | json_query("a") }} returns "" just like your experience, but {{ '{"a":"b"}' | from_json | json_query("a") }} produces "b" as one would expect

mdaniel
  • 31,240
  • 5
  • 55
  • 58