Changing the dictionary key names but not values of items in a loop

Try using JMESPath (which needs to be installed on the Ansible controller), I think this will work,

- name: Set a fact for the AdGuard Home static leases
  ansible.builtin.set_fact:
    adguard_list: "{{ dhcp_reservations | community.general.json_query('[].{mac: mac_address, ip: number, hostname: name}') }}"

- name: Print the AdGuard Home static leases list
  ansible.builtin.debug:
    var: adguard_list

You could skip the fact setting step if you want and use the above as the body for the uri module.

I find the JMESPath Terminal really handy for working out queries like this:

3 Likes