- Ansible for Network Automation
- Ansible Ad Hoc commands:
- Ansible CLI Playbook
- Appendix
- Appendix
- to take full backup
- Appendix
- Troubleshooting
Ansible for Network Automation
- install GNS3 GUI
- install and setup GNS3 VM
First Lab to test GNS3 setup
- Create a lab with 2 PC and 1 SW
- add IP address for PCs
PC1> ip 10.1.1.1 255.255.255.0
- test a ping from one PC to another
- remember to
save
device configuration
Importing image to GNS3
Goto Edit -> Preferences -> Dynamips -> ISO Routers
- click New -> Browse the image (bin)
- Choose Yes when ask for decompress
- remember to refer the Cisco/GNS3 site for minimum memory requirement
Importing appliance to GNS3
https://docs.gns3.com/1_3RdgLWgfk4ylRr99htYZrGMoFlJcmKAAaUAc8x9Ph8/index.html
- Download applicance file from website
Configure a router
sh ip int br # show ip interface details
conf t # configure terminal
copy running-config startup-config
# save running configuration to startup
NetworkAutomation Component
- download NetworkAutomation Component appliance from marketpalce which is a docker image with Ansible pre-installed.
Ansible Network Modules and Adhoc commands
root@NetworkAutomation-1:~# ansible S1 -m raw -a "show version" -u david -k
Ref:
- https://docs.ansible.com/ansible/latest/modules.html
- https://docs.ansible.com/ansible/latest/modules_by_category.html
- https://docs.ansible.com/ansible/latest/raw_module.html
Ansible Ad Hoc commands:
root@NetworkAutomation-1:~# ansible S1 -m raw -a "show version" -u david -k
root@NetworkAutomation-1:~# ansible S1 -m raw -a "show run" -u david -k
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show version" -u david -k
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show version" -u david -k | grep flash0
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show version" -u david -k | grep 'SUCCESS\|Software'
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show version" -u david -k | grep 'SUCCESS\|Version'
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show run" -u david -k | grep 'username'
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show run" -u david -k | grep 'SUCCESS\|username'
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show run" -u david -k | grep 'username' > usernames.txt
root@NetworkAutomation-1:~# cat usernames.txt
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show run" -u david -k > shrun.txt
root@NetworkAutomation-1:~# cat shrun.txt
root@NetworkAutomation-1:~# more shrun.txt
root@NetworkAutomation-1:~# ansible gns3-core -i ./gns3hosts -m raw -a "show ver" -u david -k > shver.txt
root@NetworkAutomation-1:~# more shver.txt | grep Version
root@NetworkAutomation-1:~# more shver.txt | grep 'SUCCESS\|Version'
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show arp" -u david -k
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show arp" -u david -k | grep 71
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show arp" -u david -k | grep 'SUCCESS\|71'
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show arp" -u david -k | grep 'SUCCESS\|\.71'
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show mac address-table" -u david -k
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show mac address-table" -u david -k | grep 7a
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show mac address-table" -u david -k | grep 'SUCCESS\|fe7a'
root@NetworkAutomation-1:~# ansible all -i gns3hosts -m raw -a "show mac address-table" -u david -k | grep 'SUCCESS\|fe7a'
root@NetworkAutomation-1:~# cat gns3hosts
Ansible CLI Playbook
Appendix
HP : https://docs.gns3.com/appliances/hp-vsr1001.html
Nested Virtualization - VirtualBox https://www.virtualbox.org/manual/ch09.html#nested-virt
Driver is probably stuck stopping/starting
Steps:
Navigate to “C:\Program Files\Oracle\VirtualBox\drivers\vboxdrv” Right click on “VBoxDrv.inf” file and select Install option Open the Console as a administrator and run the following command
vboxmanage cli
https://blog.scottlowe.org/2016/11/10/intro-to-vbox-cli/
vboxmanage startvm k8s vboxmanage list runningvms
https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm
vboxmanage modifyvm Ubuntu –nested-hw-virt on
Instal vmware workstation ubuntu
https://phoenixnap.com/kb/install-vmware-workstation-ubuntu
Add IP to VM
sudo ip addr add 192.168.1.14/24 dev eth0
sudo ip link set dev eth0 up
sudo ip route add default via 192.168.1.1
sudo vi /etc/network/interfaces
sudo /etc/init.d/networking restart
To configure a dynamic or Static IP address
auto eth0
iface eth0 inet dhcp
## Or configure a static IP
auto eth0
iface eth0 inet static
address 192.168.1.14
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
Configure VLAN with IP
conf t
int vlan 100
ip address IP subnet
VLANs
show vlans
ac-02#vlan database
ac-02(vlan)#
ac-02(config)#int vlan 100
# create vlan interface
ac-02(config)#no interface vlan 100
# delete vlan interface
assign to port
ac-02(config)#interface range fastEthernet 1/0 - 5
ac-02(config-if-range)#switchport mode access
ac-02(config-if-range)#switchport access vlan 100
assign IP to VLAN
ac-02(config)#interface vlan 100
ac-02(config-if)#ip address 10.1.10.70 255.255.255.0
Appendix
https://srijit.com/working-cisco-ios-gns3/
to take full backup
terminal length 0 show run
Configure HP Switch (5130)
https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-c03182828#N10013 http://patg.net/ansible,comware,switches/2014/10/16/ansible-comware/ https://porter.io/github.com/HPENetworking/ansible-hpe-cw7
Ansible Modules
- https://hp-ansible.readthedocs.io/en/latest/list_of_All_modules.html
- https://github.com/HPENetworking/ansible-hpe-cw7
Configuring password authentication for console login
<HPE> system-view
[HPE] line aux 0
[HPE-line-aux0] authentication-mode password
# Password is password
[HPE-line-aux0] set authentication password simple <PASSWORD>
[HPE-line-aux0] user-role network-admin
# save config
[HPE-line-aux0] save force
SSH on vty
[ds-01]line vty 0
[ds-01-line-vty0]authentication-mode scheme
[ds-01-line-vty0]set authentication password simple password
[ds-01-line-vty0]protocol inbound ssh
[ds-01-line-vty0]user-role network-admin
Configuring SSH login on the device
- Create a key ```