Considering the following test playbook:
---
- name: Playbook
hosts: localhost
become: false
gather_facts: false
vars:
first:
alpha: 1
gamma: 3
second:
beta: 2
tasks:
- name: Import facts
ansible.builtin.import_role:
name: helm
tasks_from: facts
- name: Debug
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.dict', first | combine(second)) }}"
Which produces the expected key, value
result:
ok: [localhost] =>
msg:
- key: alpha
value: 1
- key: gamma
value: 3
- key: beta
value: 2
While applying the dictsort
filter (documentation):
msg: "{{ lookup('ansible.builtin.dict', first | combine(second) | dictsort) }}"
The following error is produced:
fatal: [localhost]: FAILED! =>
msg: 'An unhandled exception occurred while running the lookup plugin ''ansible.builtin.dict''. Error was a <class ''ansible.errors.AnsibleError''>, original message: with_dict expects a dict. with_dict expects a dict'
I was wondering what is the proper dictsort
usage, thank you for your input.