Stage 2.3 - Ansible

Return to Workshop

Stage 2 Ansible Basics

Estimated time to complete: 45 minutes

Stages

In Stage 2, we will discuss Ansible basics.

We will run through some of the commands and concepts to better understand Ansible.

Utilizing Ansible to configure network devices in minutes.

Allows us to easily deploy and test changes prior to releasing it to production.


Here are the requirements for Stage 2

Requirements

Here is a diagram of Stage 2. This shows all the technology we will be using in Stage 2.

It also defines the use cases we will be working on in Stage 2.

Diagram

Here is a summary of Stage 2

Stage 2 Summary

Let’s try Ansible on Server 1

Change Directory to the following

cd ~/network-automation/backup/

Run the build Ansible playbook which will create a folder of today’s date

ansible-playbook playbooks/make_folder.yaml -v

After running the ls command notice the new folder based on the date

ls
cloud_user@ed26757f4b2c:~/network-automation/backup$ ls
ansible.cfg  inventory  playbooks
cloud_user@ed26757f4b2c:~/network-automation/backup$ ansible-playbook playbooks/make_folder.yaml -v
Using /home/cloud_user/network-automation/backup/ansible.cfg as config file

PLAY [CAPTURE DATE AND CREATE DIRECTORY] *****************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************
ok: [localhost]

TASK [Capture Date] *****************************************************************************************************************
ok: [localhost -> localhost] => {"changed": false, "cmd": ["date", "+%Y-%m-%d"], "delta": "0:00:00.003057", "end": "2023-08-21 16:47:36.684209", "rc": 0, "start": "2023-08-21 16:47:36.681152", "stderr": "", "stderr_lines": [], "stdout": "2023-08-21", "stdout_lines": ["2023-08-21"]}

TASK [Create Directory] *****************************************************************************************************************
changed: [localhost] => {"changed": true, "gid": 1001, "group": "cloud_user", "mode": "0775", "owner": "cloud_user", "path": "/home/cloud_user/network-automation/backup/2023-08-21", "size": 4096, "state": "directory", "uid": 1001}

PLAY RECAP *****************************************************************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   




cloud_user@ed26757f4b2c:~/network-automation/backup$ ls
2023-08-21  ansible.cfg  inventory  playbooks

So what are we trying to accomplish…​..

We need to get configurations on the switches, make changes, validate the changes and then test the changes

To start let’s automate the following with Ansible:

  • Basic IP Connectivity

  • Basic BGP

  • VLANs

  • VXLAN

  • SNMP

Let’s Add A Configuration To The Switches

Run the build Ansible playbook and beware of the error.  This is to be expected.

cd ~/network-automation/build/
ansible-playbook build.yaml -v
This error highlights the use of collections or modules from different manufacturers
cloud_user@ed26757f4b2c:~/network-automation/build$ ansible-playbook build.yaml -v
Using /home/cloud_user/network-automation/build/ansible.cfg as config file
ERROR! couldn't resolve module/action 'arista.eos.eos_snmp_server'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/cloud_user/network-automation/build/build.yaml': line 111, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: CONFIGURE SNMP
      ^ here
cloud_user@ed26757f4b2c:~/network-automation/build$ ansible-galaxy collection install arista.eos
Process install dependency map
Starting collection install process
Installing 'arista.eos:6.1.2' to '/home/cloud_user/.ansible/collections/ansible_collections/arista/eos'
Installing 'ansible.netcommon:5.2.0' to '/home/cloud_user/.ansible/collections/ansible_collections/ansible/netcommon'
Installing 'ansible.utils:2.11.0' to '/home/cloud_user/.ansible/collections/ansible_collections/ansible/utils'
cloud_user@ed26757f4b2c:~/network-automation/build$

Install the arista_eos module

ansible-galaxy collection install arista.eos

Run the playbook again

ansible-playbook build.yaml -v
cloud_user@ed26757f4b1c:~/network-automation/build$ ansible-playbook build.yaml -v
Using /home/cloud_user/network-automation/build/ansible.cfg as config file
[WARNING]: Collection arista.eos does not support Ansible version 2.12.10

PLAY [BUILD SPINE ARISTA SWITCHES] ****************************************************************************************************

TASK [CONFIGURE BGP] ******************************************************************************************************************
changed: [clab-Arista-2s-3l-spine1] => {"changed": true, "commands": ["router bgp 100", "neighbor 192.168.1.2 remote-as 201", "neighbor 192.168.2.2 remote-as 202", "neighbor 192.168.3.2 remote-as 203", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"], "session": "ansible_170260570230", "updates": ["router bgp 100", "neighbor 192.168.1.2 remote-as 201", "neighbor 192.168.2.2 remote-as 202", "neighbor 192.168.3.2 remote-as 203", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"]}
changed: [clab-Arista-2s-3l-spine2] => {"changed": true, "commands": ["router bgp 100", "neighbor 192.168.10.2 remote-as 201", "neighbor 192.168.20.2 remote-as 202", "neighbor 192.168.30.2 remote-as 203", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"], "session": "ansible_170260570264", "updates": ["router bgp 100", "neighbor 192.168.10.2 remote-as 201", "neighbor 192.168.20.2 remote-as 202", "neighbor 192.168.30.2 remote-as 203", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"]}

TASK [CONFIGURE INTERFACE ETHERNET 1] *************************************************************************************************
changed: [clab-Arista-2s-3l-spine2] => {"changed": true, "commands": ["interface ethernet 1", "no switchport", "ip address 192.168.10.1/24", "no shutdown"], "session": "ansible_170260571317", "updates": ["interface ethernet 1", "no switchport", "ip address 192.168.10.1/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-spine1] => {"changed": true, "commands": ["interface ethernet 1", "no switchport", "ip address 192.168.1.1/24", "no shutdown"], "session": "ansible_170260571314", "updates": ["interface ethernet 1", "no switchport", "ip address 192.168.1.1/24", "no shutdown"]}

TASK [CONFIGURE INTERFACE ETHERNET 2] *************************************************************************************************
changed: [clab-Arista-2s-3l-spine1] => {"changed": true, "commands": ["interface ethernet 2", "no switchport", "ip address 192.168.2.1/24", "no shutdown"], "session": "ansible_170260572752", "updates": ["interface ethernet 2", "no switchport", "ip address 192.168.2.1/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-spine2] => {"changed": true, "commands": ["interface ethernet 2", "no switchport", "ip address 192.168.20.1/24", "no shutdown"], "session": "ansible_170260572753", "updates": ["interface ethernet 2", "no switchport", "ip address 192.168.20.1/24", "no shutdown"]}

TASK [CONFIGURE INTERFACE ETHERNET 3] *************************************************************************************************
changed: [clab-Arista-2s-3l-spine2] => {"changed": true, "commands": ["interface ethernet 3", "no switchport", "ip address 192.168.30.1/24", "no shutdown"], "session": "ansible_170260573626", "updates": ["interface ethernet 3", "no switchport", "ip address 192.168.30.1/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-spine1] => {"changed": true, "commands": ["interface ethernet 3", "no switchport", "ip address 192.168.3.1/24", "no shutdown"], "session": "ansible_170260573640", "updates": ["interface ethernet 3", "no switchport", "ip address 192.168.3.1/24", "no shutdown"]}

PLAY [BUILD LEAF ARISTA SWITCHES] *****************************************************************************************************

TASK [CONFIGURE BGP] ******************************************************************************************************************
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["router bgp 201", "neighbor 192.168.1.1 remote-as 100", "neighbor 192.168.10.1 remote-as 100", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"], "session": "ansible_170260575431", "updates": ["router bgp 201", "neighbor 192.168.1.1 remote-as 100", "neighbor 192.168.10.1 remote-as 100", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"]}
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["router bgp 202", "neighbor 192.168.2.1 remote-as 100", "neighbor 192.168.20.1 remote-as 100", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"], "session": "ansible_170260575464", "updates": ["router bgp 202", "neighbor 192.168.2.1 remote-as 100", "neighbor 192.168.20.1 remote-as 100", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"]}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["router bgp 203", "neighbor 192.168.3.1 remote-as 100", "neighbor 192.168.30.1 remote-as 100", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"], "session": "ansible_170260575470", "updates": ["router bgp 203", "neighbor 192.168.3.1 remote-as 100", "neighbor 192.168.30.1 remote-as 100", "maximum-paths 2 ecmp 2", "redistribute connected", "ip routing"]}

TASK [CONFIGURE  VLANS] ***************************************************************************************************************
changed: [clab-Arista-2s-3l-leaf1] => (item=11) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 11"], "item": 11, "session": "ansible_170260577052", "updates": ["vlan 11"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf3] => (item=11) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 11"], "item": 11, "session": "ansible_170260577024", "updates": ["vlan 11"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf2] => (item=11) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 11"], "item": 11, "session": "ansible_170260577062", "updates": ["vlan 11"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf1] => (item=12) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 12"], "item": 12, "session": "ansible_170260577608", "updates": ["vlan 12"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf3] => (item=12) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 12"], "item": 12, "session": "ansible_170260577654", "updates": ["vlan 12"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf2] => (item=12) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 12"], "item": 12, "session": "ansible_170260577687", "updates": ["vlan 12"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf1] => (item=13) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 13"], "item": 13, "session": "ansible_170260577991", "updates": ["vlan 13"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf3] => (item=13) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 13"], "item": 13, "session": "ansible_170260578176", "updates": ["vlan 13"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}
changed: [clab-Arista-2s-3l-leaf2] => (item=13) => {"ansible_loop_var": "item", "changed": true, "commands": ["vlan 13"], "item": 13, "session": "ansible_170260578199", "updates": ["vlan 13"], "warnings": ["To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device", "To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device"]}

TASK [CONFIGURE INTERFACE ETHERNET 1] *************************************************************************************************
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["interface ethernet 1", "no switchport", "ip address 192.168.1.2/24", "no shutdown"], "session": "ansible_170260578792", "updates": ["interface ethernet 1", "no switchport", "ip address 192.168.1.2/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["interface ethernet 1", "no switchport", "ip address 192.168.3.2/24", "no shutdown"], "session": "ansible_170260578785", "updates": ["interface ethernet 1", "no switchport", "ip address 192.168.3.2/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["interface ethernet 1", "no switchport", "ip address 192.168.2.2/24", "no shutdown"], "session": "ansible_170260578784", "updates": ["interface ethernet 1", "no switchport", "ip address 192.168.2.2/24", "no shutdown"]}

TASK [CONFIGURE INTERFACE ETHERNET 2] *************************************************************************************************
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["interface ethernet 2", "no switchport", "ip address 192.168.20.2/24", "no shutdown"], "session": "ansible_170260579440", "updates": ["interface ethernet 2", "no switchport", "ip address 192.168.20.2/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["interface ethernet 2", "no switchport", "ip address 192.168.30.2/24", "no shutdown"], "session": "ansible_170260579446", "updates": ["interface ethernet 2", "no switchport", "ip address 192.168.30.2/24", "no shutdown"]}
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["interface ethernet 2", "no switchport", "ip address 192.168.10.2/24", "no shutdown"], "session": "ansible_170260579451", "updates": ["interface ethernet 2", "no switchport", "ip address 192.168.10.2/24", "no shutdown"]}

TASK [CONFIGURE INTERFACE LOOPBACK 1] *************************************************************************************************
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["interface loopback 1", "ip address 10.255.255.12/32"], "session": "ansible_170260579966", "updates": ["interface loopback 1", "ip address 10.255.255.12/32"]}
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["interface loopback 1", "ip address 10.255.255.11/32"], "session": "ansible_170260579951", "updates": ["interface loopback 1", "ip address 10.255.255.11/32"]}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["interface loopback 1", "ip address 10.255.255.13/32"], "session": "ansible_170260579976", "updates": ["interface loopback 1", "ip address 10.255.255.13/32"]}

TASK [CONFIGURE INTERFACE ETHERNET 3] *************************************************************************************************
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["interface ethernet 3", "switchport mode access", "switchport access vlan 11"], "session": "ansible_170260580485", "updates": ["interface ethernet 3", "switchport mode access", "switchport access vlan 11"]}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["interface ethernet 3", "switchport mode access", "switchport access vlan 13"], "session": "ansible_170260580514", "updates": ["interface ethernet 3", "switchport mode access", "switchport access vlan 13"]}
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["interface ethernet 3", "switchport mode access", "switchport access vlan 11"], "session": "ansible_170260580511", "updates": ["interface ethernet 3", "switchport mode access", "switchport access vlan 11"]}

TASK [CONFIGURE VXLAN 1] **************************************************************************************************************
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["interface vxlan 1", "vxlan source-interface loopback 1", "vxlan vlan 13 vni 3333", "vxlan flood vtep 10.255.255.11 10.255.255.12", "no shutdown"], "session": "ansible_170260580974", "updates": ["interface vxlan 1", "vxlan source-interface loopback 1", "vxlan vlan 13 vni 3333", "vxlan flood vtep 10.255.255.11 10.255.255.12", "no shutdown"]}
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["interface vxlan 1", "vxlan source-interface loopback 1", "vxlan vlan 11 vni 1111", "vxlan flood vtep 10.255.255.12 10.255.255.13", "no shutdown"], "session": "ansible_170260580975", "updates": ["interface vxlan 1", "vxlan source-interface loopback 1", "vxlan vlan 11 vni 1111", "vxlan flood vtep 10.255.255.12 10.255.255.13", "no shutdown"]}
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["interface vxlan 1", "vxlan source-interface loopback 1", "vxlan vlan 11 vni 1111", "vxlan flood vtep 10.255.255.11 10.255.255.13", "no shutdown"], "session": "ansible_170260580985", "updates": ["interface vxlan 1", "vxlan source-interface loopback 1", "vxlan vlan 11 vni 1111", "vxlan flood vtep 10.255.255.11 10.255.255.13", "no shutdown"]}

TASK [CONFIGURE INTERFACE VLAN] *******************************************************************************************************
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "commands": ["interface vlan 11", "ip address virtual 192.168.11.1/24"], "session": "ansible_170260581825", "updates": ["interface vlan 11", "ip address virtual 192.168.11.1/24"]}
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "commands": ["interface vlan 12", "ip address virtual 192.168.12.1/24"], "session": "ansible_170260581825", "updates": ["interface vlan 12", "ip address virtual 192.168.12.1/24"]}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "commands": ["interface vlan 13", "ip address virtual 192.168.13.1/24"], "session": "ansible_170260581843", "updates": ["interface vlan 13", "ip address virtual 192.168.13.1/24"]}

TASK [CONFIGURE SNMP] *****************************************************************************************************************
changed: [clab-Arista-2s-3l-leaf2] => {"after": {"communities": [{"acl_v4": "list3", "name": "netdevops", "ro": true, "view": "view1"}], "contact": "admin", "hosts": [{"host": "host02", "user": "user1", "version": "2c"}], "traps": {"bgp": {"enabled": true}, "capacity": {"arista_hardware_utilization_alert": true}}}, "before": {}, "changed": true, "commands": ["snmp-server host host02 version 2c user1", "snmp-server community netdevops view view1 list3", "snmp-server contact admin", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert"]}
changed: [clab-Arista-2s-3l-leaf1] => {"after": {"communities": [{"acl_v4": "list3", "name": "netdevops", "ro": true, "view": "view1"}], "contact": "admin", "hosts": [{"host": "host02", "user": "user1", "version": "2c"}], "traps": {"bgp": {"enabled": true}, "capacity": {"arista_hardware_utilization_alert": true}}}, "before": {}, "changed": true, "commands": ["snmp-server host host02 version 2c user1", "snmp-server community netdevops view view1 list3", "snmp-server contact admin", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert"]}
changed: [clab-Arista-2s-3l-leaf3] => {"after": {"communities": [{"acl_v4": "list3", "name": "netdevops", "ro": true, "view": "view1"}], "contact": "admin", "hosts": [{"host": "host02", "user": "user1", "version": "2c"}], "traps": {"bgp": {"enabled": true}, "capacity": {"arista_hardware_utilization_alert": true}}}, "before": {}, "changed": true, "commands": ["snmp-server host host02 version 2c user1", "snmp-server community netdevops view view1 list3", "snmp-server contact admin", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert"]}

PLAY RECAP ****************************************************************************************************************************
clab-Arista-2s-3l-leaf1    : ok=9    changed=9    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-leaf2    : ok=9    changed=9    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-leaf3    : ok=9    changed=9    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-spine1   : ok=4    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-spine2   : ok=4    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
cloud_user@ed26757f4b1c:~/network-automation/build$

Login to a Leaf switch and check out the routing table and the running configuration

Both the username and password are admin

ssh admin@clab-Arista-2s-3l-leaf1
cloud_user@ed26757f4b2c:~/network-automation/build$ ssh admin@clab-Arista-2s-3l-leaf1
Password: 
leaf1>ena
leaf1#sho ip route
VRF: default
Codes: C - connected, S - static, K - kernel, 
       O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1,
       E2 - OSPF external type 2, N1 - OSPF NSSA external type 1,
       N2 - OSPF NSSA external type2, B - BGP, B I - iBGP, B E - eBGP,
       R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2,
       O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary,
       NG - Nexthop Group Static Route, V - VXLAN Control Service,
       DH - DHCP client installed default route, M - Martian,
       DP - Dynamic Policy Route, L - VRF Leaked,
       RC - Route Cache Route
Gateway of last resort:
 S        0.0.0.0/0 [1/0] via 172.20.20.1, Management0
 C        10.255.255.11/32 is directly connected, Loopback1
 B E      10.255.255.12/32 [200/0] via 192.168.1.1, Ethernet1
                                   via 192.168.10.1, Ethernet2
 B E      10.255.255.13/32 [200/0] via 192.168.1.1, Ethernet1
                                   via 192.168.10.1, Ethernet2
 C        172.20.20.0/24 is directly connected, Management0
 C        192.168.1.0/24 is directly connected, Ethernet1
 B E      192.168.2.0/24 [200/0] via 192.168.1.1, Ethernet1
 B E      192.168.3.0/24 [200/0] via 192.168.1.1, Ethernet1
 C        192.168.10.0/24 is directly connected, Ethernet2

Let’s Backup the Switch Configurations

Change Directory to the following:

cd ~/network-automation/backup/

Run the build Ansible playbook

ansible-playbook playbooks/manual_backup.yaml -v

Check out the configurations in the dated directory

cloud_user@ed26757f4b2c:~/network-automation/backup$ ls
2023-08-21  ansible.cfg  inventory  playbooks
cloud_user@ed26757f4b1c:~/network-automation/backup$ ansible-playbook playbooks/manual_backup.yaml -v
Using /home/cloud_user/network-automation/backup/ansible.cfg as config file
[WARNING]: Collection arista.eos does not support Ansible version 2.12.10

PLAY [CAPTURE DATE AND CREATE DIRECTORY] *************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************
ok: [localhost]

TASK [Capture Date] **********************************************************************************************************
ok: [localhost] => {"changed": false, "cmd": ["date", "+%Y-%m-%d"], "delta": "0:00:00.004556", "end": "2023-12-15 22:07:30.590342", "msg": "", "rc": 0, "start": "2023-12-15 22:07:30.585786", "stderr": "", "stderr_lines": [], "stdout": "2023-12-15", "stdout_lines": ["2023-12-15"]}

TASK [Create Directory] ******************************************************************************************************
ok: [localhost] => {"changed": false, "gid": 1001, "group": "cloud_user", "mode": "0775", "owner": "cloud_user", "path": "/home/cloud_user/network-automation/backup/2023-12-15", "size": 4096, "state": "directory", "uid": 1001}

PLAY [BACKUP ARISTA SWITCHES] ************************************************************************************************

TASK [ARISTA SWITCH CONFIG] **************************************************************************************************
ok: [clab-Arista-2s-3l-leaf2] => {"changed": false, "stdout": ["! Command: show running-config\n! device: leaf2 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$E81C2KK6TBRF3SsE$88rxHXMvR.gFSVemWXXUdh/1uiYyNL5bGTW9mo3N.Tkzsb8X5fy7HT87h5CXo73sNZS8jE.FDRfB/OLCwzVRe1\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname leaf2\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\nvlan 11-13\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.2.2/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.20.2/24\n!\ninterface Ethernet3\n   switchport access vlan 11\n!\ninterface Loopback1\n   ip address 10.255.255.12/32\n!\ninterface Management0\n   ip address 172.20.20.22/24\n   ipv6 address 2001:172:20:20::22/64\n!\ninterface Vlan12\n   ip address virtual 192.168.12.1/24\n!\ninterface Vxlan1\n   vxlan source-interface Loopback1\n   vxlan udp-port 4789\n   vxlan vlan 11 vni 1111\n   vxlan flood vtep 10.255.255.11 10.255.255.13\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 202\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.2.1 remote-as 100\n   neighbor 192.168.20.1 remote-as 100\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend"], "stdout_lines": [["! Command: show running-config", "! device: leaf2 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))", "!", "no aaa root", "!", "username admin privilege 15 role network-admin secret sha512 $6$E81C2KK6TBRF3SsE$88rxHXMvR.gFSVemWXXUdh/1uiYyNL5bGTW9mo3N.Tkzsb8X5fy7HT87h5CXo73sNZS8jE.FDRfB/OLCwzVRe1", "!", "transceiver qsfp default-mode 4x10G", "!", "service routing protocols model multi-agent", "!", "hostname leaf2", "!", "snmp-server contact admin", "snmp-server community netdevops view view1 ro list3", "snmp-server host host02 version 2c user1", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert", "!", "spanning-tree mode mstp", "!", "vlan 11-13", "!", "interface Ethernet1", "   no switchport", "   ip address 192.168.2.2/24", "!", "interface Ethernet2", "   no switchport", "   ip address 192.168.20.2/24", "!", "interface Ethernet3", "   switchport access vlan 11", "!", "interface Loopback1", "   ip address 10.255.255.12/32", "!", "interface Management0", "   ip address 172.20.20.22/24", "   ipv6 address 2001:172:20:20::22/64", "!", "interface Vlan12", "   ip address virtual 192.168.12.1/24", "!", "interface Vxlan1", "   vxlan source-interface Loopback1", "   vxlan udp-port 4789", "   vxlan vlan 11 vni 1111", "   vxlan flood vtep 10.255.255.11 10.255.255.13", "!", "ip routing", "!", "ip route 0.0.0.0/0 172.20.20.1", "!", "ipv6 route ::/0 2001:172:20:20::1", "!", "router bgp 202", "   maximum-paths 2 ecmp 2", "   neighbor 192.168.2.1 remote-as 100", "   neighbor 192.168.20.1 remote-as 100", "   redistribute connected", "!", "management api http-commands", "   no shutdown", "!", "management api gnmi", "   transport grpc default", "!", "management api netconf", "   transport ssh default", "!", "end"]]}
ok: [clab-Arista-2s-3l-spine1] => {"changed": false, "stdout": ["! Command: show running-config\n! device: spine1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$t9PRdvQXd/nmnvpY$ta23FPylEu6TRIitr4xoZIbfVyfMV7iTZw.voSt.3E1vezjDSkOeqrS2bphCavF.1PBuwhcOU96gfZHm4x1Ze/\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname spine1\n!\nspanning-tree mode mstp\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.1.1/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.2.1/24\n!\ninterface Ethernet3\n   no switchport\n   ip address 192.168.3.1/24\n!\ninterface Management0\n   ip address 172.20.20.11/24\n   ipv6 address 2001:172:20:20::11/64\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 100\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.1.2 remote-as 201\n   neighbor 192.168.2.2 remote-as 202\n   neighbor 192.168.3.2 remote-as 203\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend"], "stdout_lines": [["! Command: show running-config", "! device: spine1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))", "!", "no aaa root", "!", "username admin privilege 15 role network-admin secret sha512 $6$t9PRdvQXd/nmnvpY$ta23FPylEu6TRIitr4xoZIbfVyfMV7iTZw.voSt.3E1vezjDSkOeqrS2bphCavF.1PBuwhcOU96gfZHm4x1Ze/", "!", "transceiver qsfp default-mode 4x10G", "!", "service routing protocols model multi-agent", "!", "hostname spine1", "!", "spanning-tree mode mstp", "!", "interface Ethernet1", "   no switchport", "   ip address 192.168.1.1/24", "!", "interface Ethernet2", "   no switchport", "   ip address 192.168.2.1/24", "!", "interface Ethernet3", "   no switchport", "   ip address 192.168.3.1/24", "!", "interface Management0", "   ip address 172.20.20.11/24", "   ipv6 address 2001:172:20:20::11/64", "!", "ip routing", "!", "ip route 0.0.0.0/0 172.20.20.1", "!", "ipv6 route ::/0 2001:172:20:20::1", "!", "router bgp 100", "   maximum-paths 2 ecmp 2", "   neighbor 192.168.1.2 remote-as 201", "   neighbor 192.168.2.2 remote-as 202", "   neighbor 192.168.3.2 remote-as 203", "   redistribute connected", "!", "management api http-commands", "   no shutdown", "!", "management api gnmi", "   transport grpc default", "!", "management api netconf", "   transport ssh default", "!", "end"]]}
ok: [clab-Arista-2s-3l-spine2] => {"changed": false, "stdout": ["! Command: show running-config\n! device: spine2 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$ZnFdyRi0OCa5vnjr$R78IeZZS4UjkhyGu0eKjlP0YyTZ.q2wdfgDqH0P38xlInlLfYARdLs6hKffICpxmI.2banMoNv2PY9wNN5K0.1\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname spine2\n!\nspanning-tree mode mstp\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.10.1/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.20.1/24\n!\ninterface Ethernet3\n   no switchport\n   ip address 192.168.30.1/24\n!\ninterface Management0\n   ip address 172.20.20.12/24\n   ipv6 address 2001:172:20:20::12/64\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 100\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.10.2 remote-as 201\n   neighbor 192.168.20.2 remote-as 202\n   neighbor 192.168.30.2 remote-as 203\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend"], "stdout_lines": [["! Command: show running-config", "! device: spine2 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))", "!", "no aaa root", "!", "username admin privilege 15 role network-admin secret sha512 $6$ZnFdyRi0OCa5vnjr$R78IeZZS4UjkhyGu0eKjlP0YyTZ.q2wdfgDqH0P38xlInlLfYARdLs6hKffICpxmI.2banMoNv2PY9wNN5K0.1", "!", "transceiver qsfp default-mode 4x10G", "!", "service routing protocols model multi-agent", "!", "hostname spine2", "!", "spanning-tree mode mstp", "!", "interface Ethernet1", "   no switchport", "   ip address 192.168.10.1/24", "!", "interface Ethernet2", "   no switchport", "   ip address 192.168.20.1/24", "!", "interface Ethernet3", "   no switchport", "   ip address 192.168.30.1/24", "!", "interface Management0", "   ip address 172.20.20.12/24", "   ipv6 address 2001:172:20:20::12/64", "!", "ip routing", "!", "ip route 0.0.0.0/0 172.20.20.1", "!", "ipv6 route ::/0 2001:172:20:20::1", "!", "router bgp 100", "   maximum-paths 2 ecmp 2", "   neighbor 192.168.10.2 remote-as 201", "   neighbor 192.168.20.2 remote-as 202", "   neighbor 192.168.30.2 remote-as 203", "   redistribute connected", "!", "management api http-commands", "   no shutdown", "!", "management api gnmi", "   transport grpc default", "!", "management api netconf", "   transport ssh default", "!", "end"]]}
ok: [clab-Arista-2s-3l-leaf3] => {"changed": false, "stdout": ["! Command: show running-config\n! device: leaf3 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$cuBgDiwSd5fW54iG$rdXNFA1ZorpqIjzmjD6K7L8bexKNubMfEbjIKBAykfRI/RbPb6VykUpTYBIUlIJsEJ0aoRhKxniEu.u8bbIkT1\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname leaf3\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\nvlan 11-13\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.3.2/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.30.2/24\n!\ninterface Ethernet3\n   switchport access vlan 13\n!\ninterface Loopback1\n   ip address 10.255.255.13/32\n!\ninterface Management0\n   ip address 172.20.20.23/24\n   ipv6 address 2001:172:20:20::23/64\n!\ninterface Vlan13\n   ip address virtual 192.168.13.1/24\n!\ninterface Vxlan1\n   vxlan source-interface Loopback1\n   vxlan udp-port 4789\n   vxlan vlan 13 vni 3333\n   vxlan flood vtep 10.255.255.11 10.255.255.12\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 203\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.3.1 remote-as 100\n   neighbor 192.168.30.1 remote-as 100\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend"], "stdout_lines": [["! Command: show running-config", "! device: leaf3 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))", "!", "no aaa root", "!", "username admin privilege 15 role network-admin secret sha512 $6$cuBgDiwSd5fW54iG$rdXNFA1ZorpqIjzmjD6K7L8bexKNubMfEbjIKBAykfRI/RbPb6VykUpTYBIUlIJsEJ0aoRhKxniEu.u8bbIkT1", "!", "transceiver qsfp default-mode 4x10G", "!", "service routing protocols model multi-agent", "!", "hostname leaf3", "!", "snmp-server contact admin", "snmp-server community netdevops view view1 ro list3", "snmp-server host host02 version 2c user1", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert", "!", "spanning-tree mode mstp", "!", "vlan 11-13", "!", "interface Ethernet1", "   no switchport", "   ip address 192.168.3.2/24", "!", "interface Ethernet2", "   no switchport", "   ip address 192.168.30.2/24", "!", "interface Ethernet3", "   switchport access vlan 13", "!", "interface Loopback1", "   ip address 10.255.255.13/32", "!", "interface Management0", "   ip address 172.20.20.23/24", "   ipv6 address 2001:172:20:20::23/64", "!", "interface Vlan13", "   ip address virtual 192.168.13.1/24", "!", "interface Vxlan1", "   vxlan source-interface Loopback1", "   vxlan udp-port 4789", "   vxlan vlan 13 vni 3333", "   vxlan flood vtep 10.255.255.11 10.255.255.12", "!", "ip routing", "!", "ip route 0.0.0.0/0 172.20.20.1", "!", "ipv6 route ::/0 2001:172:20:20::1", "!", "router bgp 203", "   maximum-paths 2 ecmp 2", "   neighbor 192.168.3.1 remote-as 100", "   neighbor 192.168.30.1 remote-as 100", "   redistribute connected", "!", "management api http-commands", "   no shutdown", "!", "management api gnmi", "   transport grpc default", "!", "management api netconf", "   transport ssh default", "!", "end"]]}
ok: [clab-Arista-2s-3l-leaf1] => {"changed": false, "stdout": ["! Command: show running-config\n! device: leaf1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$HaTzWV1udlSiPVZG$hc43B0.R2it6MwKiYJC9xh62li4MOgGNRs2Sa.xYAhoirzbE3D5Piu8nhcDyR2IdgvmJsawvdOHLEIg9EJIR50\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname leaf1\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\nvlan 11-13\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.1.2/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.10.2/24\n!\ninterface Ethernet3\n   switchport access vlan 11\n!\ninterface Loopback1\n   ip address 10.255.255.11/32\n!\ninterface Management0\n   ip address 172.20.20.21/24\n   ipv6 address 2001:172:20:20::21/64\n!\ninterface Vlan11\n   ip address virtual 192.168.11.1/24\n!\ninterface Vxlan1\n   vxlan source-interface Loopback1\n   vxlan udp-port 4789\n   vxlan vlan 11 vni 1111\n   vxlan flood vtep 10.255.255.12 10.255.255.13\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 201\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.1.1 remote-as 100\n   neighbor 192.168.10.1 remote-as 100\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend"], "stdout_lines": [["! Command: show running-config", "! device: leaf1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))", "!", "no aaa root", "!", "username admin privilege 15 role network-admin secret sha512 $6$HaTzWV1udlSiPVZG$hc43B0.R2it6MwKiYJC9xh62li4MOgGNRs2Sa.xYAhoirzbE3D5Piu8nhcDyR2IdgvmJsawvdOHLEIg9EJIR50", "!", "transceiver qsfp default-mode 4x10G", "!", "service routing protocols model multi-agent", "!", "hostname leaf1", "!", "snmp-server contact admin", "snmp-server community netdevops view view1 ro list3", "snmp-server host host02 version 2c user1", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert", "!", "spanning-tree mode mstp", "!", "vlan 11-13", "!", "interface Ethernet1", "   no switchport", "   ip address 192.168.1.2/24", "!", "interface Ethernet2", "   no switchport", "   ip address 192.168.10.2/24", "!", "interface Ethernet3", "   switchport access vlan 11", "!", "interface Loopback1", "   ip address 10.255.255.11/32", "!", "interface Management0", "   ip address 172.20.20.21/24", "   ipv6 address 2001:172:20:20::21/64", "!", "interface Vlan11", "   ip address virtual 192.168.11.1/24", "!", "interface Vxlan1", "   vxlan source-interface Loopback1", "   vxlan udp-port 4789", "   vxlan vlan 11 vni 1111", "   vxlan flood vtep 10.255.255.12 10.255.255.13", "!", "ip routing", "!", "ip route 0.0.0.0/0 172.20.20.1", "!", "ipv6 route ::/0 2001:172:20:20::1", "!", "router bgp 201", "   maximum-paths 2 ecmp 2", "   neighbor 192.168.1.1 remote-as 100", "   neighbor 192.168.10.1 remote-as 100", "   redistribute connected", "!", "management api http-commands", "   no shutdown", "!", "management api gnmi", "   transport grpc default", "!", "management api netconf", "   transport ssh default", "!", "end"]]}

TASK [SAVE ARISTA SWITCH CONFIG] *********************************************************************************************

changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "checksum": "54ad1167d3ddad876741e96d6a17cbaed181428e", "dest": "/home/cloud_user/network-automation/backup/2023-12-15/show_run_clab-Arista-2s-3l-leaf1.txt", "gid": 1001, "group": "cloud_user", "md5sum": "d070a016bbb56659d551383903aac149", "mode": "0664", "owner": "cloud_user", "size": 1568, "src": "/home/cloud_user/.ansible/tmp/ansible-local-27222bjvssoch/ansible-tmp-1702678064.872667-27663-173009155840628/source", "state": "file", "uid": 1001}
changed: [clab-Arista-2s-3l-spine1] => {"changed": true, "checksum": "4967972fad5c6443e18958e2c5fef7ff2d3ac858", "dest": "/home/cloud_user/network-automation/backup/2023-12-15/show_run_clab-Arista-2s-3l-spine1.txt", "gid": 1001, "group": "cloud_user", "md5sum": "ded8b75add772fe664785c077a2400e3", "mode": "0664", "owner": "cloud_user", "size": 1130, "src": "/home/cloud_user/.ansible/tmp/ansible-local-27222bjvssoch/ansible-tmp-1702678065.0516748-27665-35258970898487/source", "state": "file", "uid": 1001}
changed: [clab-Arista-2s-3l-leaf2] => {"changed": true, "checksum": "db23d93ad7cf231dbcf5a789b8a5d3f3728d90ea", "dest": "/home/cloud_user/network-automation/backup/2023-12-15/show_run_clab-Arista-2s-3l-leaf2.txt", "gid": 1001, "group": "cloud_user", "md5sum": "551a2ab9975fa8c8f7fad6c6da1cd5c4", "mode": "0664", "owner": "cloud_user", "size": 1568, "src": "/home/cloud_user/.ansible/tmp/ansible-local-27222bjvssoch/ansible-tmp-1702678064.6424618-27664-266882372791207/source", "state": "file", "uid": 1001}
changed: [clab-Arista-2s-3l-leaf3] => {"changed": true, "checksum": "63caedddb472fb93565a09a57b4aa505bae0b883", "dest": "/home/cloud_user/network-automation/backup/2023-12-15/show_run_clab-Arista-2s-3l-leaf3.txt", "gid": 1001, "group": "cloud_user", "md5sum": "0cedc0650c70b1e689a5219623e3404e", "mode": "0664", "owner": "cloud_user", "size": 1568, "src": "/home/cloud_user/.ansible/tmp/ansible-local-27222bjvssoch/ansible-tmp-1702678064.9631824-27667-77275659410087/source", "state": "file", "uid": 1001}
changed: [clab-Arista-2s-3l-spine2] => {"changed": true, "checksum": "a280b20e9f215062fb87a31520b46bd0d2fcab14", "dest": "/home/cloud_user/network-automation/backup/2023-12-15/show_run_clab-Arista-2s-3l-spine2.txt", "gid": 1001, "group": "cloud_user", "md5sum": "7c59f75c0e9249afb35cb156a4809886", "mode": "0664", "owner": "cloud_user", "size": 1136, "src": "/home/cloud_user/.ansible/tmp/ansible-local-27222bjvssoch/ansible-tmp-1702678064.7496052-27668-161632831639499/source", "state": "file", "uid": 1001}

PLAY RECAP *******************************************************************************************************************
clab-Arista-2s-3l-leaf1    : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-leaf2    : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-leaf3    : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-spine1   : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-spine2   : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

cloud_user@ed26757f4b1c:~/network-automation/backup$
2023-07-31  2023-12-15  ansible.cfg  inventory  playbooks
cloud_user@ed26757f4b1c:~/network-automation/backup$ cd 2023-12-15/ (1)
cloud_user@ed26757f4b1c:~/network-automation/backup/2023-12-15$ ls
show_run_clab-Arista-2s-3l-leaf1.txt  show_run_clab-Arista-2s-3l-leaf3.txt   show_run_clab-Arista-2s-3l-spine2.txt
show_run_clab-Arista-2s-3l-leaf2.txt  show_run_clab-Arista-2s-3l-spine1.txt
cloud_user@ed26757f4b1c:~/network-automation/backup/2023-12-15$
1 Replace with the correct date

Let’s Document The Devices with Ansible

Change Directory to the following

cd ~/network-automation/document/

This playbook will create a custom index.html file with the ansible facts provided from the switches

Run the build Ansible playbook

ansible-playbook document.yaml -v
cloud_user@ed26757f4b1c:~/network-automation/document$ ansible-playbook document.yaml -v
Using /home/cloud_user/network-automation/document/ansible.cfg as config file

PLAY [DOCUMENT ARISTA DEVICES] ********************************************************************************************************

TASK [Collect all facts from device] **************************************************************************************************
[WARNING]: default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards
ok: [clab-Arista-2s-3l-spine1] => {"ansible_facts": {"ansible_net_all_ipv4_addresses": ["172.20.20.11", "192.168.2.1", "192.168.3.1", "192.168.1.1"], "ansible_net_all_ipv6_addresses": ["2001:172:20:20::11"], "ansible_net_api": "cliconf", "ansible_net_config": "! Command: show running-config\n! device: spine1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$84QcMIvV/9HvN92Q$07fQPh1nBPDc4C.qq1tQtbYNZraaGtH1v.e.F/6BcWewp.1jI.ZbKf5TwgJdX3VlGX49Y1nZ3I9bwhT0W/j6R0\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname spine1\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.1.1/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.2.1/24\n!\ninterface Ethernet3\n   no switchport\n   ip address 192.168.3.1/24\n!\ninterface Management0\n   ip address 172.20.20.11/24\n   ipv6 address 2001:172:20:20::11/64\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 100\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.1.2 remote-as 201\n   neighbor 192.168.2.2 remote-as 202\n   neighbor 192.168.3.2 remote-as 203\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend", "ansible_net_filesystems": ["file:", "flash:", "system:"], "ansible_net_fqdn": "spine1", "ansible_net_gather_network_resources": [], "ansible_net_gather_subset": ["config", "interfaces", "hardware", "default"], "ansible_net_hostname": "spine1", "ansible_net_interfaces": {"Ethernet1": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.1.1", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:3d:79:43", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet2": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.2.1", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:41:7e:23", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet3": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.3.1", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:15:e9:ee", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Management0": {"bandwidth": 1000000000, "description": "", "duplex": "duplexFull", "ipv4": {"address": "172.20.20.11", "masklen": 24}, "ipv6": {"address": "2001:172:20:20::11", "subnet": "2001:172:20:20::/64"}, "lineprotocol": "up", "macaddress": "00:1c:73:13:fa:14", "mtu": 1500, "operstatus": "connected", "type": "routed"}}, "ansible_net_memfree_mb": 1054.43359375, "ansible_net_memtotal_mb": 7858.04296875, "ansible_net_model": "cEOSLab", "ansible_net_neighbors": {"Ethernet1": [{"host": "leaf1", "port": "Ethernet1"}], "Ethernet2": [{"host": "leaf2", "port": "Ethernet1"}], "Ethernet3": [{"host": "leaf3", "port": "Ethernet1"}], "Management0": [{"host": "spine2", "port": "Management0"}, {"host": "leaf2", "port": "Management0"}, {"host": "leaf3", "port": "Management0"}, {"host": "leaf1", "port": "Management0"}]}, "ansible_net_python_version": "3.8.10", "ansible_net_serialnum": "", "ansible_net_system": "eos", "ansible_net_version": "4.25.10M-29053933.42510M (engineering build)", "ansible_network_resources": {}}, "changed": false}
ok: [clab-Arista-2s-3l-leaf3] => {"ansible_facts": {"ansible_net_all_ipv4_addresses": ["172.20.20.23", "0.0.0.0", "10.255.255.13", "192.168.30.2", "192.168.3.2", "0.0.0.0"], "ansible_net_all_ipv6_addresses": ["2001:172:20:20::23"], "ansible_net_api": "cliconf", "ansible_net_config": "! Command: show running-config\n! device: leaf3 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$EQmxK.aXDTpX1jb8$RqOzWQ4kjEKCAEuO99WZjCcKt8Anqsx33ueBv8areESEMT/DVDYwU6cC4kvsf8.oGfGAoZo5fQQYZ3muiBDbu.\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname leaf3\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\nvlan 11-14\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.3.2/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.30.2/24\n!\ninterface Ethernet3\n   switchport access vlan 14\n!\ninterface Loopback1\n   ip address 10.255.255.13/32\n!\ninterface Management0\n   ip address 172.20.20.23/24\n   ipv6 address 2001:172:20:20::23/64\n!\ninterface Vlan13\n   ip address virtual 192.168.13.1/24\n!\ninterface Vlan14\n   ip address virtual 192.168.14.1/24\n!\ninterface Vxlan1\n   vxlan source-interface Loopback1\n   vxlan udp-port 4789\n   vxlan vlan 13 vni 3333\n   vxlan flood vtep 10.255.255.11 10.255.255.12\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 203\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.3.1 remote-as 100\n   neighbor 192.168.30.1 remote-as 100\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend", "ansible_net_filesystems": ["file:", "flash:", "system:"], "ansible_net_fqdn": "leaf3", "ansible_net_gather_network_resources": [], "ansible_net_gather_subset": ["interfaces", "default", "config", "hardware"], "ansible_net_hostname": "leaf3", "ansible_net_interfaces": {"Ethernet1": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.3.2", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:46:48:5f", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet2": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.30.2", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:3b:84:6b", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet3": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {}, "lineprotocol": "up", "macaddress": "aa:c1:ab:c2:fd:8f", "mtu": 9214, "operstatus": "connected", "type": "bridged"}, "Loopback1": {"bandwidth": 0, "description": "", "ipv4": {"address": "10.255.255.13", "masklen": 32}, "lineprotocol": "up", "mtu": 65535, "operstatus": "connected", "type": "routed"}, "Management0": {"bandwidth": 1000000000, "description": "", "duplex": "duplexFull", "ipv4": {"address": "172.20.20.23", "masklen": 24}, "ipv6": {"address": "2001:172:20:20::23", "subnet": "2001:172:20:20::/64"}, "lineprotocol": "up", "macaddress": "00:1c:73:b2:4d:1b", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Vlan13": {"bandwidth": 0, "description": "", "ipv4": {"address": "0.0.0.0", "masklen": 0}, "lineprotocol": "up", "macaddress": "00:1c:73:49:0b:f2", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Vlan14": {"bandwidth": 0, "description": "", "ipv4": {"address": "0.0.0.0", "masklen": 0}, "lineprotocol": "up", "macaddress": "00:1c:73:49:0b:f2", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Vxlan1": {"bandwidth": 0, "description": "", "ipv4": {}, "lineprotocol": "up", "mtu": 0, "operstatus": "connected", "type": "bridged"}}, "ansible_net_memfree_mb": 1054.43359375, "ansible_net_memtotal_mb": 7858.04296875, "ansible_net_model": "cEOSLab", "ansible_net_neighbors": {"Ethernet1": [{"host": "spine1", "port": "Ethernet3"}], "Ethernet2": [{"host": "spine2", "port": "Ethernet3"}], "Management0": [{"host": "leaf2", "port": "Management0"}, {"host": "spine2", "port": "Management0"}, {"host": "spine1", "port": "Management0"}, {"host": "leaf1", "port": "Management0"}]}, "ansible_net_python_version": "3.8.10", "ansible_net_serialnum": "", "ansible_net_system": "eos", "ansible_net_version": "4.25.10M-29053933.42510M (engineering build)", "ansible_network_resources": {}}, "changed": false}
ok: [clab-Arista-2s-3l-spine2] => {"ansible_facts": {"ansible_net_all_ipv4_addresses": ["172.20.20.12", "192.168.20.1", "192.168.30.1", "192.168.10.1"], "ansible_net_all_ipv6_addresses": ["2001:172:20:20::12"], "ansible_net_api": "cliconf", "ansible_net_config": "! Command: show running-config\n! device: spine2 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$ueuan3eNB4CTup4j$umPw4vGcSYLfZOod4COVkf0AoO8fPHmDqNZmq9BC7ykE5KuNlP4PQWpZB2d6l4TGuDCfbZmNHWatZVQ0BSmCz0\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname spine2\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.10.1/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.20.1/24\n!\ninterface Ethernet3\n   no switchport\n   ip address 192.168.30.1/24\n!\ninterface Management0\n   ip address 172.20.20.12/24\n   ipv6 address 2001:172:20:20::12/64\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 100\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.10.2 remote-as 201\n   neighbor 192.168.20.2 remote-as 202\n   neighbor 192.168.30.2 remote-as 203\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend", "ansible_net_filesystems": ["file:", "flash:", "system:"], "ansible_net_fqdn": "spine2", "ansible_net_gather_network_resources": [], "ansible_net_gather_subset": ["interfaces", "config", "hardware", "default"], "ansible_net_hostname": "spine2", "ansible_net_interfaces": {"Ethernet1": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.10.1", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:29:7f:7b", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet2": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.20.1", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:1c:83:0e", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet3": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.30.1", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:6a:96:33", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Management0": {"bandwidth": 1000000000, "description": "", "duplex": "duplexFull", "ipv4": {"address": "172.20.20.12", "masklen": 24}, "ipv6": {"address": "2001:172:20:20::12", "subnet": "2001:172:20:20::/64"}, "lineprotocol": "up", "macaddress": "00:1c:73:0d:dd:48", "mtu": 1500, "operstatus": "connected", "type": "routed"}}, "ansible_net_memfree_mb": 1054.43359375, "ansible_net_memtotal_mb": 7858.04296875, "ansible_net_model": "cEOSLab", "ansible_net_neighbors": {"Ethernet1": [{"host": "leaf1", "port": "Ethernet2"}], "Ethernet2": [{"host": "leaf2", "port": "Ethernet2"}], "Ethernet3": [{"host": "leaf3", "port": "Ethernet2"}], "Management0": [{"host": "leaf2", "port": "Management0"}, {"host": "leaf3", "port": "Management0"}, {"host": "spine1", "port": "Management0"}, {"host": "leaf1", "port": "Management0"}]}, "ansible_net_python_version": "3.8.10", "ansible_net_serialnum": "", "ansible_net_system": "eos", "ansible_net_version": "4.25.10M-29053933.42510M (engineering build)", "ansible_network_resources": {}}, "changed": false}
ok: [clab-Arista-2s-3l-leaf1] => {"ansible_facts": {"ansible_net_all_ipv4_addresses": ["172.20.20.21", "0.0.0.0", "10.255.255.11", "192.168.10.2", "192.168.1.2"], "ansible_net_all_ipv6_addresses": ["2001:172:20:20::21"], "ansible_net_api": "cliconf", "ansible_net_config": "! Command: show running-config\n! device: leaf1 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$Up403xRlkfMqgiWI$T1dcmJ4CQPCOve4Cwc/l8kCkJPYAPNURdPbJ4oGNqX1RZmJ.C.SahoIWR5AEjccgRPJ8rA6CSY/tIfUJw0PDH.\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname leaf1\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\nvlan 11-13\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.1.2/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.10.2/24\n!\ninterface Ethernet3\n   switchport access vlan 11\n!\ninterface Loopback1\n   ip address 10.255.255.11/32\n!\ninterface Management0\n   ip address 172.20.20.21/24\n   ipv6 address 2001:172:20:20::21/64\n!\ninterface Vlan11\n   ip address virtual 192.168.11.1/24\n!\ninterface Vxlan1\n   vxlan source-interface Loopback1\n   vxlan udp-port 4789\n   vxlan vlan 11 vni 1111\n   vxlan flood vtep 10.255.255.12 10.255.255.13\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 201\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.1.1 remote-as 100\n   neighbor 192.168.10.1 remote-as 100\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend", "ansible_net_filesystems": ["file:", "flash:", "system:"], "ansible_net_fqdn": "leaf1", "ansible_net_gather_network_resources": [], "ansible_net_gather_subset": ["default", "config", "hardware", "interfaces"], "ansible_net_hostname": "leaf1", "ansible_net_interfaces": {"Ethernet1": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.1.2", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:67:dc:68", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet2": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.10.2", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:47:05:06", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet3": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {}, "lineprotocol": "up", "macaddress": "aa:c1:ab:7b:69:7e", "mtu": 9214, "operstatus": "connected", "type": "bridged"}, "Loopback1": {"bandwidth": 0, "description": "", "ipv4": {"address": "10.255.255.11", "masklen": 32}, "lineprotocol": "up", "mtu": 65535, "operstatus": "connected", "type": "routed"}, "Management0": {"bandwidth": 1000000000, "description": "", "duplex": "duplexFull", "ipv4": {"address": "172.20.20.21", "masklen": 24}, "ipv6": {"address": "2001:172:20:20::21", "subnet": "2001:172:20:20::/64"}, "lineprotocol": "up", "macaddress": "00:1c:73:48:87:f7", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Vlan11": {"bandwidth": 0, "description": "", "ipv4": {"address": "0.0.0.0", "masklen": 0}, "lineprotocol": "up", "macaddress": "00:1c:73:56:b8:bb", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Vxlan1": {"bandwidth": 0, "description": "", "ipv4": {}, "lineprotocol": "up", "mtu": 0, "operstatus": "connected", "type": "bridged"}}, "ansible_net_memfree_mb": 1054.43359375, "ansible_net_memtotal_mb": 7858.04296875, "ansible_net_model": "cEOSLab", "ansible_net_neighbors": {"Ethernet1": [{"host": "spine1", "port": "Ethernet1"}], "Ethernet2": [{"host": "spine2", "port": "Ethernet1"}], "Management0": [{"host": "leaf2", "port": "Management0"}, {"host": "spine2", "port": "Management0"}, {"host": "leaf3", "port": "Management0"}, {"host": "spine1", "port": "Management0"}]}, "ansible_net_python_version": "3.8.10", "ansible_net_serialnum": "", "ansible_net_system": "eos", "ansible_net_version": "4.25.10M-29053933.42510M (engineering build)", "ansible_network_resources": {}}, "changed": false}
ok: [clab-Arista-2s-3l-leaf2] => {"ansible_facts": {"ansible_net_all_ipv4_addresses": ["172.20.20.22", "0.0.0.0", "10.255.255.12", "192.168.20.2", "192.168.2.2"], "ansible_net_all_ipv6_addresses": ["2001:172:20:20::22"], "ansible_net_api": "cliconf", "ansible_net_config": "! Command: show running-config\n! device: leaf2 (cEOSLab, EOS-4.25.10M-29053933.42510M (engineering build))\n!\nno aaa root\n!\nusername admin privilege 15 role network-admin secret sha512 $6$TecUxPCMKMrOMKPF$oIDr1wk8i6Sp5K9l8Jml3RTugImTO34V6.C1oeYWGFyftQVDYDTJO.p3XlC8M9LSJn61a.08HuND7truUfTVQ1\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\nhostname leaf2\n!\nsnmp-server contact admin\nsnmp-server community netdevops view view1 ro list3\nsnmp-server host host02 version 2c user1\nsnmp-server enable traps bgp\nsnmp-server enable traps capacity arista-hardware-utilization-alert\n!\nspanning-tree mode mstp\n!\nvlan 11-13\n!\ninterface Ethernet1\n   no switchport\n   ip address 192.168.2.2/24\n!\ninterface Ethernet2\n   no switchport\n   ip address 192.168.20.2/24\n!\ninterface Ethernet3\n   switchport access vlan 11\n!\ninterface Loopback1\n   ip address 10.255.255.12/32\n!\ninterface Management0\n   ip address 172.20.20.22/24\n   ipv6 address 2001:172:20:20::22/64\n!\ninterface Vlan12\n   ip address virtual 192.168.12.1/24\n!\ninterface Vxlan1\n   vxlan source-interface Loopback1\n   vxlan udp-port 4789\n   vxlan vlan 11 vni 1111\n   vxlan flood vtep 10.255.255.11 10.255.255.13\n!\nip routing\n!\nip route 0.0.0.0/0 172.20.20.1\n!\nipv6 route ::/0 2001:172:20:20::1\n!\nrouter bgp 202\n   maximum-paths 2 ecmp 2\n   neighbor 192.168.2.1 remote-as 100\n   neighbor 192.168.20.1 remote-as 100\n   redistribute connected\n!\nmanagement api http-commands\n   no shutdown\n!\nmanagement api gnmi\n   transport grpc default\n!\nmanagement api netconf\n   transport ssh default\n!\nend", "ansible_net_filesystems": ["file:", "flash:", "system:"], "ansible_net_fqdn": "leaf2", "ansible_net_gather_network_resources": [], "ansible_net_gather_subset": ["hardware", "config", "default", "interfaces"], "ansible_net_hostname": "leaf2", "ansible_net_interfaces": {"Ethernet1": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.2.2", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:f9:2f:22", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet2": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {"address": "192.168.20.2", "masklen": 24}, "lineprotocol": "up", "macaddress": "aa:c1:ab:1e:cf:62", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Ethernet3": {"bandwidth": 0, "description": "", "duplex": "duplexFull", "ipv4": {}, "lineprotocol": "up", "macaddress": "aa:c1:ab:e1:c3:11", "mtu": 9214, "operstatus": "connected", "type": "bridged"}, "Loopback1": {"bandwidth": 0, "description": "", "ipv4": {"address": "10.255.255.12", "masklen": 32}, "lineprotocol": "up", "mtu": 65535, "operstatus": "connected", "type": "routed"}, "Management0": {"bandwidth": 1000000000, "description": "", "duplex": "duplexFull", "ipv4": {"address": "172.20.20.22", "masklen": 24}, "ipv6": {"address": "2001:172:20:20::22", "subnet": "2001:172:20:20::/64"}, "lineprotocol": "up", "macaddress": "00:1c:73:88:a7:63", "mtu": 1500, "operstatus": "connected", "type": "routed"}, "Vlan12": {"bandwidth": 0, "description": "", "ipv4": {"address": "0.0.0.0", "masklen": 0}, "lineprotocol": "lowerLayerDown", "macaddress": "00:1c:73:f5:b4:4b", "mtu": 1500, "operstatus": "notconnect", "type": "routed"}, "Vxlan1": {"bandwidth": 0, "description": "", "ipv4": {}, "lineprotocol": "up", "mtu": 0, "operstatus": "connected", "type": "bridged"}}, "ansible_net_memfree_mb": 1054.43359375, "ansible_net_memtotal_mb": 7858.04296875, "ansible_net_model": "cEOSLab", "ansible_net_neighbors": {"Ethernet1": [{"host": "spine1", "port": "Ethernet2"}], "Ethernet2": [{"host": "spine2", "port": "Ethernet2"}], "Management0": [{"host": "spine2", "port": "Management0"}, {"host": "leaf3", "port": "Management0"}, {"host": "spine1", "port": "Management0"}, {"host": "leaf1", "port": "Management0"}]}, "ansible_net_python_version": "3.8.10", "ansible_net_serialnum": "", "ansible_net_system": "eos", "ansible_net_version": "4.25.10M-29053933.42510M (engineering build)", "ansible_network_resources": {}}, "changed": false}

TASK [Display result] *****************************************************************************************************************
ok: [clab-Arista-2s-3l-leaf1] => {
    "msg": "Model is leaf1 and it is running 4.25.10M-29053933.42510M (engineering build)"
}
ok: [clab-Arista-2s-3l-leaf2] => {
    "msg": "Model is leaf2 and it is running 4.25.10M-29053933.42510M (engineering build)"
}
ok: [clab-Arista-2s-3l-leaf3] => {
    "msg": "Model is leaf3 and it is running 4.25.10M-29053933.42510M (engineering build)"
}
ok: [clab-Arista-2s-3l-spine2] => {
    "msg": "Model is spine2 and it is running 4.25.10M-29053933.42510M (engineering build)"
}
ok: [clab-Arista-2s-3l-spine1] => {
    "msg": "Model is spine1 and it is running 4.25.10M-29053933.42510M (engineering build)"
}

TASK [Generate document] **************************************************************************************************************
changed: [clab-Arista-2s-3l-leaf1] => {"changed": true, "checksum": "c7046fbecd82a5b78ccc540eca465ada04e25f5e", "dest": "./index.html", "gid": 1001, "group": "cloud_user", "md5sum": "4b4508d5ac9936186e05b33f34f6e380", "mode": "0664", "owner": "cloud_user", "size": 18002, "src": "/home/cloud_user/.ansible/tmp/ansible-local-83597avvxgapw/ansible-tmp-1703369042.6580818-84062-219447733712636/source", "state": "file", "uid": 1001}

PLAY RECAP ****************************************************************************************************************************
clab-Arista-2s-3l-leaf1    : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-leaf2    : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-leaf3    : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-spine1   : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
clab-Arista-2s-3l-spine2   : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

cloud_user@ed26757f4b1c:~/network-automation/document$

Now that we created the custom index.html file

We need to create a Web Server

Lets build a Docker container and use Nginx as the Web Server

Lets review the Dockerfile in the document folder

This is a basic Dockerfile to use the latest version of Nginx to copy the files from the document folder to the /usr/share/nginx/html directory in the new container.

FROM nginx:latest
WORKDIR /usr/share/nginx/html
COPY  . .

We need to first build the custom docker container using the following command:

docker build -t netdevops-nginx:1.0 .

Run the following command to list the docker images

docker image ls
cloud_user@ed26757f4b1c:~/network-automation/document$ docker build -t netdevops-nginx:1.0 .
[+] Building 1.1s (8/8) FINISHED                                                                                        docker:default
 => [internal] load build definition from Dockerfile                                                                              0.0s
 => => transferring dockerfile: 96B                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                 0.0s
 => => transferring context: 2B                                                                                                   0.0s
 => [internal] load metadata for docker.io/library/nginx:latest                                                                   0.6s
 => [1/3] FROM docker.io/library/nginx:latest@sha256:2bdc49f2f8ae8d8dc50ed00f2ee56d00385c6f8bc8a8b320d0a294d9e3b49026             0.0s
 => [internal] load build context                                                                                                 0.0s
 => => transferring context: 19.22kB                                                                                              0.0s
 => CACHED [2/3] WORKDIR /usr/share/nginx/html                                                                                    0.0s
 => [3/3] COPY  . .                                                                                                               0.3s
 => exporting to image                                                                                                            0.0s
 => => exporting layers                                                                                                           0.0s
 => => writing image sha256:305ce7012b657798dffe4fadd4feb5020b42fb11e51ee01b5aa5945d43828109                                      0.0s
 => => naming to docker.io/library/netdevops-nginx:1.0                                                                            0.0s
cloud_user@ed26757f4b1c:~/network-automation/document$ docker image ls
REPOSITORY                        TAG        IMAGE ID       CREATED          SIZE
netdevops-nginx                   1.0        305ce7012b65   14 seconds ago   187MB
ceos                              4.25.10M   2e63b981e0f1   6 days ago       1.62GB
batfish/allinone                  latest     32fb95468c4a   7 days ago       1.54GB
ghcr.io/hellt/network-multitool   latest     ee228f411287   2 years ago      270MB
cloud_user@ed26757f4b1c:~/network-automation/document$

Now let’s run the docker image on port 80 using the following command:

docker run -d -p 80:80 --name netdevops-nginx netdevops-nginx:1.0

Run the following command to see all the containters running on Server 1

docker ps
cloud_user@ed26757f4b1c:~/network-automation/document$ docker run -d -p 80:80 --name netdevops-nginx netdevops-nginx:1.0
e303ddfbbdea6142cd70d95601196ce1e75254fc0efd3c689585bfe21e1af640
cloud_user@ed26757f4b1c:~/network-automation/document$ docker ps
CONTAINER ID   IMAGE                             COMMAND                  CREATED          STATUS          PORTS                                     NAMES
e303ddfbbdea   netdevops-nginx:1.0               "/docker-entrypoint.…"   8 seconds ago    Up 7 seconds    0.0.0.0:80->80/tcp, :::80->80/tcp         netdevops-nginx (1)
b5518c6fff61   ceos:4.25.10M                     "bash -c '/mnt/flash…"   45 minutes ago   Up 45 minutes   0.0.0.0:8023->22/tcp, :::8023->22/tcp     clab-Arista-2s-3l-leaf3
5df56c409c52   ceos:4.25.10M                     "bash -c '/mnt/flash…"   45 minutes ago   Up 45 minutes   0.0.0.0:8022->22/tcp, :::8022->22/tcp     clab-Arista-2s-3l-leaf2
4529a1888049   ghcr.io/hellt/network-multitool   "/docker-entrypoint.…"   45 minutes ago   Up 45 minutes   80/tcp, 443/tcp                           clab-Arista-2s-3l-client3
44faae49385c   ceos:4.25.10M                     "bash -c '/mnt/flash…"   45 minutes ago   Up 45 minutes   0.0.0.0:8021->22/tcp, :::8021->22/tcp     clab-Arista-2s-3l-leaf1
798e8af2dcbc   ghcr.io/hellt/network-multitool   "/docker-entrypoint.…"   45 minutes ago   Up 45 minutes   80/tcp, 443/tcp                           clab-Arista-2s-3l-client1
a52373f39cda   ceos:4.25.10M                     "bash -c '/mnt/flash…"   45 minutes ago   Up 45 minutes   0.0.0.0:8012->22/tcp, :::8012->22/tcp     clab-Arista-2s-3l-spine2
f50a53f554d1   ghcr.io/hellt/network-multitool   "/docker-entrypoint.…"   45 minutes ago   Up 45 minutes   80/tcp, 443/tcp                           clab-Arista-2s-3l-client2
694b11906820   ceos:4.25.10M                     "bash -c '/mnt/flash…"   45 minutes ago   Up 45 minutes   0.0.0.0:8011->22/tcp, :::8011->22/tcp     clab-Arista-2s-3l-spine1
1 New Nginx container

Open a Web Browser and go to the FQDN of Server 1


s2 5
Figure 1: Network Automation Web Page

If you want to troubleshoot the container

Login to the console of the container using the following command:

docker exec -it netdevops-nginx /bin/bash
cloud_user@ed26757f4b1c:~/network-automation/document$ docker exec -it netdevops-nginx /bin/bash
root@e303ddfbbdea:/usr/share/nginx/html# ls
50x.html  Dockerfile  ansible.cfg  css  document.yaml  hosts  index.html  template.docx  template.html.j2
root@e303ddfbbdea:/usr/share/nginx/html# pwd
/usr/share/nginx/html
root@e303ddfbbdea:/usr/share/nginx/html#

Type exit to logout of the container

If you opted to configure SAMBA

Open the text files on the Samba Share.

This is where all the config files have been stored.

\\a.b.c.d\share\backup\2023-10-06

Replace a.b.c.d with your IP address and use the correct folder

End Result

At this point, you automated the backup, configuration and documentation of 5 Arista switches.

Return to Workshop