--- - name: Merge two hashes with combine gather_facts: no hosts: localhost tasks: - block: - debug: var: output - assert: that: - output.type == "person" - output.spec.firstname == "jane" - output.spec.lastname == "doe" - output.extended_spec.age == 21 - output.extra.knows == "ansible" vars: output: "{{ input1|combine(input2, recursive=True) }}" input1: type: person spec: firstname: john lastname: doe extended_spec: {} input2: spec: firstname: jane extended_spec: age: 21 extra: knows: ansible