---
- name: Get AWS Availability Zones
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Read JSON file
      slurp:
        src: az.out.json
      register: json_data

    - name: Parse JSON
      set_fact:
        az_data: "{{ json_data.content | b64decode | from_json }}"

    - name: Create list of region and zones
      set_fact:
        region_zones: "{{ region_zones | default([]) + [{ 'region_name': 
item.region_name, 'zone_names': item.zone_names }] }}"
      loop: "{{ az_data }}"

    - name: Create final output
      set_fact:
        final_output: "{{ region_zones | map(attribute='region_name') | 
unique | map('extract', region_zones) | list }}"
      run_once: true

    - debug:
        var: final_output

On Monday, December 5, 2022 at 5:28:34 PM UTC-8 Thomas Stephen Lee wrote:

> Hi,
>
> I have a small test playbook
> https://pastebin.com/kciEWPJ7
> The az.out.json is at
> https://pastebin.com/BnfaLG1N
> What I need is 
> the region_name and corresponding zone_name(s)
> listed like
> https://pastebin.com/3HQkN2yf
>
> Please guide.
>
> Thanks
> ---
>
> Lee
>

-- 
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/9b3c279d-7250-40e2-a19d-5026f2ed5561n%40googlegroups.com.

Reply via email to