community / community.yang / 1.1.0 / lookup / xml2json Converts xml input to json structure output by mapping it against corresponding Yang model Authors: Ganesh Nalawade (@ganeshrn)community.yang.xml2json (1.1.0) — lookup
Install with ansible-galaxy collection install community.yang:==1.1.0
collections: - name: community.yang version: 1.1.0
This plugin lookups the input xml data, typically Netconf rpc response received from remote host and convert it to json format as defined by RFC 7951 JSON Encoding of Data Modeled with YANG
- name: translate json to xml debug: msg="{{ lookup('community.yang.xml2json', interfaces_config.xml, yang_file='openconfig/public/release/models/interfaces/openconfig-interfaces.yang', search_path='openconfig/public/release/models:pyang/modules/') }}"
_terms: description: - Input xml file path that adheres to a given yang model. This can be a Netconf/Restconf xml rpc response that contains operational and configuration data received from remote host. required: true type: path yang_file: description: - Path to yang model file against which the xml file is validated and converted to json as per json encoding of data modeled with YANG. required: true type: path search_path: description: - This option is a colon C(:) separated list of directories to search for imported yang modules in the yang file mentioned in C(path) option. If the value is not given it will search in the current directory. required: false keep_tmp_files: default: false description: - This is a boolean flag to indicate if the intermediate files generated while validation json configuration should be kept or deleted. If the value is C(true) the files will not be deleted else by default all the intermediate files will be deleted irrespective of whether task run is successful or not. The intermediate files are stored in path C(~/.ansible/tmp/json2xml), this option is mainly used for debugging purpose. type: bool
_raw: description: The translated json structure from xml