--- - name: Setup xml and expected json ansible.builtin.set_fact: data: "interface-configurations": "@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg" "interface-configuration": output: "\n\n\t\n" - debug: msg: "{{ data|ansible.utils.to_xml() }}" - name: Integration tests with and without default engine as xmltodict and assert: that: "{{ output == item.test }}" loop: - test: "{{ data|ansible.utils.to_xml() }}" - test: "{{ data|ansible.utils.to_xml('xmltodict') }}" - name: test for supported engine for to_xml filter ansible.builtin.set_fact: data: "interface-configurations": "@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg" - name: validate input xml ansible.builtin.set_fact: _result: "{{ data|ansible.utils.to_xml('dicttoxml') }}" ignore_errors: true register: result - assert: that: "{{ msg in result.msg }}" vars: msg: "Error when using plugin 'to_xml': engine: dicttoxml is not supported"