HomeGuidesAPI Reference
GuidesAPI ReferenceGitHubAirheads Developer CommunityLog In

NAPALM with Ansible

NAPALM has integration with Ansible through the use of the napalm-ansible library. This library allows for Ansible playbooks to use NAPALM to retrieve data or modify configurations for networking devices as a collection of Ansible modules.

📘

A great source for installation and configuration instructions for Ansible with AOS-CX can be found here.
Installation and configuration instructions for the NAPALM with Ansible integration can be found in the napalm-ansible Github here

Supported Functions in napalm-ansible for AOS-CX

  • napalm_get_facts
  • napalm_ping
  • napalm_validate

Example

[aoscx]
aoscx1 ansible_host=asocx1.domain.com

[aoscx:vars]
# Must match Python that NAPALM is installed into.
ansible_python_interpreter=/path/to/venv/bin/python
ansible_network_os=aoscx
# Although specifying 'network_cli', NAPALM module will use AOS-CX REST
ansible_connection=network_cli
ansible_user=admin
ansible_ssh_pass=my_password
---
- name: NAPALM get_facts and get_interfaces
  hosts: aoscx1
  gather_facts: False
  tasks:
    - name: napalm get_facts
      napalm_get_facts:
        filter: facts,interfaces

    - debug:
        var: napalm_facts
$ ansible-playbook napalm_get_aoscx.yml

PLAY [NAPALM get_facts and get_interfaces] *********

TASK [napalm get_facts] ****************************
ok: [aoscx1]

TASK [debug] ***************************************
ok: [aoscx1] => {
    "napalm_facts": {
        "fqdn": "aoscx1",
        "hostname": "aoscx1",
        "interface_list": [
            "1/1/1",
            "1/1/2",
            "1/1/3",
            "1/1/4",
            "1/1/5",
            "1/1/6",
            "1/1/7",
            "1/1/8",
            "1/1/9",
            "1/1/10",
            "1/1/11",
            "1/1/12",
            "1/1/13",
            "1/1/14",
            "1/1/15",
            "1/1/16",
            "1/1/17",
            "1/1/18",
            "1/1/19",
            "1/1/20",
            "1/1/21",
            "1/1/22",
            "1/1/23",
            "1/1/24",
            "1/1/25",
            "1/1/26",
            "1/1/27",
            "1/1/28",
            "vlan1"
        ],
        "model": "JL666A 6300F 24G CL4 PoE 4SFP56 Sw",
        "os_version": "FL.10.05.0001BH",
        "serial_number": "",
        "uptime": 12893402,
        "vendor": "Aruba"
    }
}

PLAY RECAP ****************************************
aoscx1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0