Commit 7d3a203b authored by Bill Grant's avatar Bill Grant
Browse files

part4 complete so modifications to part3

parent 4f5f6c91
......@@ -5,9 +5,6 @@ lldp run
vlan 100
name Servers1
!
vlan 200
name Servers2
!
interface Ethernet1
description P2P Link to Spine-1
logging event link-status
......@@ -29,6 +26,13 @@ interface Ethernet2
interface loopback0
ip address 192.168.0.3/32
!
interface Ethernet9
switchport access vlan 100
no snmp trap link-status
spanning-tree portfast
spanning-tree bpduguard enable
no shutdown
!
interface Vlan100
description Servers1
mtu 9214
......
......@@ -5,9 +5,6 @@ lldp run
vlan 100
name Servers1
!
vlan 200
name Servers2
!
interface Ethernet1
description P2P Link to Spine-1
logging event link-status
......@@ -29,6 +26,13 @@ interface Ethernet2
interface loopback0
ip address 192.168.0.4/32
!
interface Ethernet9
switchport access vlan 100
no snmp trap link-status
spanning-tree portfast
spanning-tree bpduguard enable
no shutdown
!
interface Vlan100
description Servers1
mtu 9214
......@@ -41,7 +45,7 @@ match ip address prefix-list PREFIX-LIST-OUT
!
ip prefix-list PREFIX-LIST-OUT seq 10 permit 192.168.0.4/32
ip prefix-list PREFIX-LIST-OUT seq 20 permit 172.16.0.0/16
ip prefix-list PREFIX-LIST-OUT seq 30 permit
ip prefix-list PREFIX-LIST-OUT seq 30 permit 10.2.100.0/24
!
router bgp 65100
bgp log-neighbor-changes
......
......@@ -2,6 +2,7 @@
from jinja2 import Environment, FileSystemLoader
import yaml
from napalm import get_network_driver
class ConfigureLeafSpine():
......@@ -66,12 +67,29 @@ class ConfigureLeafSpine():
host=value,
vlans=self.leafs['vlans'],
routemaps=self.leafs['routemaps'],
accessinterfaces=self.leafs['accessinterfaces'],
bgp=self.leafs['bgp']
)
filename = 'configs/{0}.config'.format(key)
with open(filename, 'w') as file:
file.writelines(config)
def deployconfig(self):
"""Checks for diffs and deploys configs using NAPALM"""
driver = get_network_driver('eos')
for key, value in self.hosts.items():
device = driver(key, 'admin', 'admin')
device.open()
device.load_merge_candidate(
filename='configs/{0}.config'.format(key)
)
diffs = device.compare_config()
if diffs:
print("{0} Diffs: ".format(key))
print("\n{0}".format(diffs))
device.commit_config()
device.close()
if __name__ == "__main__":
lsconfig = ConfigureLeafSpine(
......@@ -86,3 +104,4 @@ if __name__ == "__main__":
lsconfig.generatebaseconfig()
lsconfig.generatespineconfig()
lsconfig.generateleafconfig()
lsconfig.deployconfig()
\ No newline at end of file
......@@ -140,6 +140,7 @@ leaf-2:
- name: PREFIX-LIST-OUT
action: permit
sequence: 30
ip: 10.2.100.0/24
vlaninterfaces:
- number: 100
description: Servers1
......
......@@ -23,6 +23,15 @@ interface loopback{{ loopback.number }}
ip address {{ loopback.ip }}
!
{% endfor -%}
{% for accessinterface in accessinterfaces -%}
interface Ethernet{{ accessinterface.number }}
switchport access vlan {{ accessinterface.vlan }}
no snmp trap link-status
spanning-tree portfast
spanning-tree bpduguard enable
no shutdown
!
{% endfor -%}
{% for vlaninterface in host.vlaninterfaces -%}
interface Vlan{{ vlaninterface.number }}
description {{ vlaninterface.description }}
......
......@@ -3,8 +3,11 @@
vlans:
- number: 100
description: Servers1
- number: 200
description: Servers2
accessinterfaces:
- number: 9
switchport: access
vlan: 100
routemaps:
- name: ROUTE-MAP-OUT
......
......@@ -65,6 +65,7 @@ class ConfigureLeafSpine():
config = template.render(
host=value,
vlans=self.leafs['vlans'],
accessinterfaces=self.leafs['accessinterfaces'],
routemaps=self.leafs['routemaps'],
bgp=self.leafs['bgp']
)
......
......@@ -140,6 +140,7 @@ leaf-2:
- name: PREFIX-LIST-OUT
action: permit
sequence: 30
ip: 10.2.100.0/24
vlaninterfaces:
- number: 100
description: Servers1
......
......@@ -23,6 +23,15 @@ interface loopback{{ loopback.number }}
ip address {{ loopback.ip }}
!
{% endfor -%}
{% for accessinterface in accessinterfaces -%}
interface Ethernet{{ accessinterface.number }}
switchport access vlan {{ accessinterface.vlan }}
no snmp trap link-status
spanning-tree portfast
spanning-tree bpduguard enable
no shutdown
!
{% endfor -%}
{% for vlaninterface in host.vlaninterfaces -%}
interface Vlan{{ vlaninterface.number }}
description {{ vlaninterface.description }}
......
......@@ -3,8 +3,12 @@
vlans:
- number: 100
description: Servers1
- number: 200
description: Servers2
accessinterfaces:
- number: 9
switchport: access
vlan: 100
- number: 10
routemaps:
- name: ROUTE-MAP-OUT
......
# LeafSpineAutomation
! Base configuration
!
hostname {{ hostname }}
ip name-server {{ defaults.nameserver1 }}
ip name-server {{ defaults.nameserver2 }}
ip domain-name {{ defaults.domainname }}
!
ntp source Management1
ntp server {{ defaults.ntpserver1 }} prefer
ntp server {{ defaults.ntpserver2 }}
!
username admin role network-admin secret {{ defaults.password }}
!
clock timezone {{ site.timezone }}
!
vrf definition management
!
! Use https in production
!
management api http-commands
protocol http
no shutdown
!
vrf management
no shutdown
!
interface Management1
vrf forwarding management
ip address {{ host.managementip }}
!
ip route vrf management 0.0.0.0/0 {{ host.managementgw }}
!
end
\ No newline at end of file
! Base configuration
!
hostname leaf-1
ip name-server 8.8.8.8
ip name-server 8.8.4.4
ip domain-name example.net
!
ntp source Management1
ntp server 0.pool.ntp.org prefer
ntp server 1.pool.ntp.org
!
username admin role network-admin secret admin
!
clock timezone America/New_York
!
vrf definition management
!
! Use https in production
!
management api http-commands
protocol http
no shutdown
!
vrf management
no shutdown
!
interface Management1
vrf forwarding management
ip address 198.51.100.252/24
!
ip route vrf management 0.0.0.0/0 198.51.100.1
!
end
\ No newline at end of file
ip routing
!
lldp run
!
vlan 100
name Servers1
!
interface Ethernet1
description P2P Link to Spine-1
logging event link-status
no switchport
ip address 172.16.0.2/30
arp timeout 900
mtu 9214
no shutdown
!
interface Ethernet2
description P2P Link to Spine-2
logging event link-status
no switchport
ip address 172.16.0.10/30
arp timeout 900
mtu 9214
no shutdown
!
interface loopback0
ip address 192.168.0.3/32
!
interface Ethernet9
switchport access vlan 100
no snmp trap link-status
spanning-tree portfast
spanning-tree bpduguard enable
no shutdown
!
interface Vlan100
description Servers1
mtu 9214
ip address 10.1.100.1/24
arp timeout 900
no shutdown
!
route-map ROUTE-MAP-OUT permit 10
match ip address prefix-list PREFIX-LIST-OUT
!
ip prefix-list PREFIX-LIST-OUT seq 10 permit 192.168.0.3/32
ip prefix-list PREFIX-LIST-OUT seq 20 permit 172.16.0.0/16
ip prefix-list PREFIX-LIST-OUT seq 30 permit 10.1.100.0/24
!
router bgp 65100
bgp log-neighbor-changes
distance bgp 20 200 200
maximum-paths 4 ecmp 4
neighbor EBGP-TO-SPINE peer-group
neighbor EBGP-TO-SPINE remote-as 65000
neighbor EBGP-TO-SPINE maximum-routes 12000
neighbor EBGP-TO-SPINE allowas-in 1
neighbor 172.16.0.1 peer-group EBGP-TO-SPINE
neighbor 172.16.0.9 peer-group EBGP-TO-SPINE
network 192.168.0.3/32
redistribute connected
!
end
\ No newline at end of file
! Base configuration
!
hostname leaf-2
ip name-server 8.8.8.8
ip name-server 8.8.4.4
ip domain-name example.net
!
ntp source Management1
ntp server 0.pool.ntp.org prefer
ntp server 1.pool.ntp.org
!
username admin role network-admin secret admin
!
clock timezone America/New_York
!
vrf definition management
!
! Use https in production
!
management api http-commands
protocol http
no shutdown
!
vrf management
no shutdown
!
interface Management1
vrf forwarding management
ip address 198.51.100.251/24
!
ip route vrf management 0.0.0.0/0 198.51.100.1
!
end
\ No newline at end of file
ip routing
!
lldp run
!
vlan 100
name Servers1
!
interface Ethernet1
description P2P Link to Spine-1
logging event link-status
no switchport
ip address 172.16.0.6/30
arp timeout 900
mtu 9214
no shutdown
!
interface Ethernet2
description P2P Link to Spine-2
logging event link-status
no switchport
ip address 172.16.0.14/30
arp timeout 900
mtu 9214
no shutdown
!
interface loopback0
ip address 192.168.0.4/32
!
interface Ethernet9
switchport access vlan 100
no snmp trap link-status
spanning-tree portfast
spanning-tree bpduguard enable
no shutdown
!
interface Vlan100
description Servers1
mtu 9214
ip address 10.2.100.1/24
arp timeout 900
no shutdown
!
route-map ROUTE-MAP-OUT permit 10
match ip address prefix-list PREFIX-LIST-OUT
!
ip prefix-list PREFIX-LIST-OUT seq 10 permit 192.168.0.4/32
ip prefix-list PREFIX-LIST-OUT seq 20 permit 172.16.0.0/16
ip prefix-list PREFIX-LIST-OUT seq 30 permit 10.2.100.0/24
!
router bgp 65100
bgp log-neighbor-changes
distance bgp 20 200 200
maximum-paths 4 ecmp 4
neighbor EBGP-TO-SPINE peer-group
neighbor EBGP-TO-SPINE remote-as 65000
neighbor EBGP-TO-SPINE maximum-routes 12000
neighbor EBGP-TO-SPINE allowas-in 1
neighbor 172.16.0.5 peer-group EBGP-TO-SPINE
neighbor 172.16.0.13 peer-group EBGP-TO-SPINE
network 192.168.0.4/32
redistribute connected
!
end
\ No newline at end of file
! Base configuration
!
hostname spine-1
ip name-server 8.8.8.8
ip name-server 8.8.4.4
ip domain-name example.net
!
ntp source Management1
ntp server 0.pool.ntp.org prefer
ntp server 1.pool.ntp.org
!
username admin role network-admin secret admin
!
clock timezone America/New_York
!
vrf definition management
!
! Use https in production
!
management api http-commands
protocol http
no shutdown
!
vrf management
no shutdown
!
interface Management1
vrf forwarding management
ip address 198.51.100.254/24
!
ip route vrf management 0.0.0.0/0 198.51.100.1
!
end
\ No newline at end of file
ip routing
!
lldp run
!
interface Ethernet1
description P2P Link to Leaf-1
logging event link-status
no switchport
ip address 172.16.0.1/30
arp timeout 900
no shutdown
!
interface Ethernet2
description P2P Link to Leaf-2
logging event link-status
no switchport
ip address 172.16.0.5/30
arp timeout 900
no shutdown
!
interface loopback0
ip address 192.168.0.1/32
!
router bgp 65000
bgp log-neighbor-changes
distance bgp 20 200 200
maximum-paths 4 ecmp 64
neighbor EBGP-TO-LEAF peer-group
neighbor EBGP-TO-LEAF remote-as 65100
neighbor EBGP-TO-LEAF maximum-routes 12000
neighbor 172.16.0.2 peer-group EBGP-TO-LEAF
neighbor 172.16.0.6 peer-group EBGP-TO-LEAF
network 192.168.0.1/32
!
end
\ No newline at end of file
! Base configuration
!
hostname spine-2
ip name-server 8.8.8.8
ip name-server 8.8.4.4
ip domain-name example.net
!
ntp source Management1
ntp server 0.pool.ntp.org prefer
ntp server 1.pool.ntp.org
!
username admin role network-admin secret admin
!
clock timezone America/New_York
!
vrf definition management
!
! Use https in production
!
management api http-commands
protocol http
no shutdown
!
vrf management
no shutdown
!
interface Management1
vrf forwarding management
ip address 198.51.100.253/24
!
ip route vrf management 0.0.0.0/0 198.51.100.1
!
end
\ No newline at end of file
ip routing
!
lldp run
!
interface Ethernet1
description P2P Link to Leaf-1
logging event link-status
no switchport
ip address 172.16.0.9/30
arp timeout 900
no shutdown
!
interface Ethernet2
description P2P Link to Leaf-2
logging event link-status
no switchport
ip address 172.16.0.13/30
arp timeout 900
no shutdown
!
interface loopback0
ip address 192.168.0.2/32
!
router bgp 65000
bgp log-neighbor-changes
distance bgp 20 200 200
maximum-paths 4 ecmp 64
neighbor EBGP-TO-LEAF peer-group
neighbor EBGP-TO-LEAF remote-as 65100
neighbor EBGP-TO-LEAF maximum-routes 12000
neighbor 172.16.0.10 peer-group EBGP-TO-LEAF
neighbor 172.16.0.14 peer-group EBGP-TO-LEAF
network 192.168.0.2/32
!
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment