community / community.yang / 1.1.0 / lookup / json2xml Validates json configuration against yang data model and convert it to xml. Authors: Ganesh Nalawade (@ganeshrn)community.yang.json2xml (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 json configuration, validates it against the respective yang data model which is also given as input to this plugin and coverts it to xml format which can be used as payload within Netconf rpc.
- name: translate json to xml debug: msg="{{ lookup('yang_json2xml', config_json, yang_file='openconfig/public/release/models/interfaces/openconfig-interfaces.yang', search_path='openconfig/public/release/models:pyang/modules/') }}"
_terms: description: - Input json configuration file path that adheres to a particular yang model. required: true type: path doctype: default: config description: - Specifies the target root node of the generated xml. The default value is C(config) yang_file: description: - Path to yang model file against which the json configuration is validated and converted to xml. 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 xml string from json