The following modules are currently available:
napalm_get_facts
napalm_install_config
napalm_validate
NAPALM is integrated with Ansible and it provides different NAPALM modules to interact with different vendor equipment, below is the most common NAPALM Ansible modules.
napalm_get_facts, this is used to get different output from the devices and return a common data structure.
napalm_install_config, this load the configuration into the managed nodes.
Further NAPALM emulates operation like compare Config and commit Config which is not available natively by some Networking OS like Cisco-IOS. Thus, it delivers a common API to interact with different vendors Network OS. The below diagram outlines the output of the same operation (get_bgp_neigbors) on both a JunOS and IOS-XR device and returned output, which clearly outlines the benefit of having a command API for interacting with the different Vendor equipment.
Finally, we can generate the configuration using Ansible and JINJA2 templates, and how to push the configuration to the managed nodes using NAPALM
napalm_get_facts:
Output as yaml type Dictionary rather then normal show output
use jinja2 template to format Output to more specific yaml data structure.
Good Example:
https://dodgydudes.se/ansible-net106/
Example to retrieve facts from a device:
- name: get facts from device
napalm_get_facts:
hostname={{ inventory_hostname }}
username={{ user }}
dev_os={{ os }}
password={{ passwd }}
filter='facts,interfaces,bgp_neighbors'
register: result
- name: print data
debug: var=result
List of Filters:
http://napalm.readthedocs.io/en/latest/support/
Example to install config on a device:
- assemble:
src=../compiled/{{ inventory_hostname }}/
dest=../compiled/{{ inventory_hostname }}/running.conf
- napalm_install_config:
hostname={{ inventory_hostname }}
username={{ user }}
dev_os={{ os }}
password={{ passwd }}
config_file=../compiled/{{ inventory_hostname }}/running.conf
commit_changes={{ commit_changes }}
replace_config={{ replace_config }}
get_diffs=True
diff_file=../compiled/{{ inventory_hostname }}/diff
Example to get compliance report:
- name: GET VALIDATION REPORT
napalm_validate:
username: "{{ un }}"
password: "{{ pwd }}"
hostname: "{{ inventory_hostname }}"
dev_os: "{{ dev_os }}"
validation_file: validate.yml
- name: GET VALIDATION REPORT USING PROVIDER
napalm_validate:
provider: "{{ ios_provider }}"
validation_file: validate.yml
- name: Check all interfaces are up
napalm_validate:
data: "{{ interfaces.yang_model }}"
models:
- models.openconfig_interface
validation_file: "validate.yaml"
register: report