--- - name: Set a fact ansible.builtin.set_fact: a: b: c: - 1 - 2 - name: Update the fact ansible.utils.update_fact: updates: - path: a.b.c.0 value: 10 - path: "a['b']['c'][1]" value: 20 register: updated - assert: that: "{{ updated.a == expected.a }}" vars: expected: a: b: c: - 10 - 20 - name: Update the fact ansible.utils.update_fact: updates: - path: a value: x: y: z: - 100 - true register: updated - assert: that: "{{ updated.a == expected.a }}" vars: expected: a: x: y: z: - 100 - true - name: Update the fact ansible.utils.update_fact: updates: - path: "a.b.c[{{ index }}]" value: 20 vars: index: "{{ a.b.c|ansible.utils.index_of('eq', 2) }}" register: updated - assert: that: "{{ updated.a == expected.a }}" vars: expected: a: b: c: - 1 - 20