Jinja2 Hands-On Exercises
Jinja2 Hands-On Exercises
For each exercise, create a Jinja2 document that will transform one of the
YAML documents you created in the previous set of exercises into a router
configuration. You can use the online Jinja parser to check the results.
hostname <hostname>
!
interface loopback 0
ip address <loopback> 255.255.255.255
!
banner motd #
<banner>
#
hostname <hostname>
!
interface loopback 0
ip address <loopback> 255.255.255.255
!
! for each interface
interface <interface name>
no shutdown
This material is copyrighted and licensed for the sole use by Mikel Maeso ([email protected] [85.87.178.33]). More information at http://www.ipSpace.net/Webinars
5. Using the list of users created in YAML exercise #5 create a local user
database for a Cisco IOS router. Use privilege level 2 for users without
privilege attribute.
6. Using the list of BGP neighbors created in YAML exercise #6 create Cisco
IOS BGP router configuration:
no neighbor <address>
Create a prefix list for every neighbor that has prefixes attribute.
This material is copyrighted and licensed for the sole use by Mikel Maeso ([email protected] [85.87.178.33]). More information at http://www.ipSpace.net/Webinars
8. Create a BGP router configuration using YAML document created in YAML
exercise #8:
Create common device configuration as in exercise 1
Create BGP configuration as in exercise 7
Create interfaces configuration:
---
node: E1
fabric:
- {left: E1, left_ip: 10.0.0.21, left_port: GigabitEthernet0/2,
right: E2, right_ip: 10.0.0.22, right_port: GigabitEthernet0/2,
cost: 5 }
- {left: E1, left_ip: 10.0.0.13, left_port: GigabitEthernet0/1,
right: PE1, right_ip: 10.0.0.14, right_port: GigabitEthernet0/1,
cost: 10 }
- {left: E2, left_ip: 10.0.0.17, left_port: GigabitEthernet0/1,
right: PE1, right_ip: 10.0.0.18, right_port: GigabitEthernet0/2,
cost: 1 }
- {left: E3, left_ip: 10.0.0.41, left_port: GigabitEthernet0/2,
right: E4, right_ip: 10.0.0.42, right_port: GigabitEthernet0/2 }
- {left: E3, left_ip: 10.0.0.29, left_port: GigabitEthernet0/3,
right: PE2, right_ip: 10.0.0.30, right_port: GigabitEthernet0/1 }
- {left: E4, left_ip: 10.0.0.37, left_port: GigabitEthernet0/3,
right: PE2, right_ip: 10.0.0.38, right_port: GigabitEthernet0/2 }
nodes:
- name: E1
mgmt: 172.16.1.110
rid: 192.168.0.2
- name: E2
mgmt: 172.16.2.1 255.255.255.240
rid: 192.168.0.4
1
This is an intermediately-hard exercise. You might want to solve it after getting
more hands-on Jinja2 practice.
This material is copyrighted and licensed for the sole use by Mikel Maeso ([email protected] [85.87.178.33]). More information at http://www.ipSpace.net/Webinars
Create the router configuration for node specified in the node
attribute:
hostname <name>
interface loopback 0
ip address <rid> 255.255.255.255
!
interface GigabitEthernet0/0
ip address <mgmt> ! use mask 255.255.255.0 when mask is not specified
!
! for every fabric interface
interface <port>
ip address <ip> 255.255.255.252
no shutdown
ip ospf 1 area 0
!
router ospf 1
router-id <rid>
This material is copyrighted and licensed for the sole use by Mikel Maeso ([email protected] [85.87.178.33]). More information at http://www.ipSpace.net/Webinars