36 lines
1.2 KiB
YAML
36 lines
1.2 KiB
YAML
---
|
|
- 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: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\">\n\t<interface-configuration></interface-configuration>\n</interface-configurations>"
|
|
|
|
- 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"
|