Skip to content

Latest commit

 

History

History
225 lines (188 loc) · 8.51 KB

community.yang.fetch_module.rst

File metadata and controls

225 lines (188 loc) · 8.51 KB

community.yang.fetch

Fetch given yang model and it's dependencies

  • Fetch given yang model and its dependant yang model from device using netconf rpc.

The below requirements are needed on the host that executes this module.

  • ncclient (>=v0.5.2)
  • pyang
  • xmltodict
Parameter Choices/Defaults Comments
continue_on_failure
boolean
    Choices:
  • no ←
  • yes
This is an optional arguement that allows schema fetch to continue if one the desired models fails download
dir
-
This is an optional argument which provide the directory path in which the fetched yang modules will be saved. The name of the file is same as that of the yang module name prefixed with `.yang` extension.
name
-
Name of the yang model to fetched from remote host. This will also fetch all the dependent yang models and return as part of result. If the value is set to all in that case all the yang models supported by remote host will be fetched.

Note

  • This module requires the NETCONF system service be enabled on the remote device being managed.
  • This module supports the use of connection=ansible.netcommon.netconf
  • If no options provided it will return list of yang model name supported by remote host
- name: Fetch given yang model from remote host
  community.yang.fetch:
    name: "{{ item }}"
  loop:
    - openconfig-interface
    - openconfig-bgp

- name: Fetch list of supported yang model names
  community.yang.fetch:

- name: Fetch all the yang models supported by remote host and store it in dir location
  community.yang.fetch:
    name: all
    dir: "{{ playbook_dir }}/yang_files"

- name: Fetch all the yang models supported by remote host and store it in dir location do not stop on error
  community.yang.fetch:
    name: all
    dir: "{{ playbook_dir }}/yang_files"
    continue_on_failure: true

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
failed_yang_modules
list
only when continue_on_failure is true
List of yang models that failed download

Sample:
['ietf-netconf-monitoring', 'cisco-xr-ietf-netconf-monitoring-deviations']
fetched
dictionary
always apart from low-level errors (such as action plugin)
This is a key-value pair were key is the name of the yang model and value is the yang model itself in string format

Sample:
{'ietf-inet-types': 'module ietf-inet-types ...<--snip-->'}
number_schema_fetched
integer
always apart from low-level errors (such as action plugin)
Total number of yang model fetched from remote host

Sample:
10
supported_yang_modules
list
only when model name is not provided
List of supported yang models name

Sample:
['ietf-netconf-monitoring', 'cisco-xr-ietf-netconf-monitoring-deviations']


Authors

  • Ganesh Nalawade (@ganeshrn)