community.yang.fetch (1.1.0) — module

Fetch given yang model and it's dependencies

Authors: Ganesh Nalawade (@ganeshrn)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install community.yang:==1.1.0


Add to requirements.yml

  collections:
    - name: community.yang
      version: 1.1.0

Description

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


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Fetch given yang model from remote host
  community.yang.fetch:
    name: "{{ item }}"
  loop:
    - openconfig-interface
    - openconfig-bgp
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Fetch list of supported yang model names
  community.yang.fetch:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
dir:
    description:
    - 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:
    description:
    - 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 I(all)
      in that case all the yang models supported by remote host will be fetched.

continue_on_failure:
    default: false
    description:
    - This is an optional arguement that allows schema fetch to continue if one the desired
      models fails download
    type: bool

Outputs

failed_yang_modules:
  description: List of yang models that failed download
  returned: only when continue_on_failure is true
  sample:
  - ietf-netconf-monitoring
  - cisco-xr-ietf-netconf-monitoring-deviations
  type: list
fetched:
  description: 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
  returned: always apart from low-level errors (such as action plugin)
  sample:
    ietf-inet-types: module ietf-inet-types ...<--snip-->
  type: dict
number_schema_fetched:
  description: Total number of yang model fetched from remote host
  returned: always apart from low-level errors (such as action plugin)
  sample: 10
  type: int
supported_yang_modules:
  description: List of supported yang models name
  returned: only when model name is not provided
  sample:
  - ietf-netconf-monitoring
  - cisco-xr-ietf-netconf-monitoring-deviations
  type: list