More Jinja – Working with YAM as an Input
Jinja2 Simple YAML Example¶
We’re now going to take a look at grabbing a file from the hard drive written in YAML syntax. YAML is arguably the most human readable data serialization format which makes it really easy for coders and non-coders alike to work with.
We’re going to build on the last Jinja2 example. Instead of creating the templates and variables directly in python. We’re going to load them instead from files on our computer.
This may seem like a small detail, but this allows us to deconstruct the building of our configurations, meaning that different people can be responsible for different components of the configuration. As with anything, if you can break a complex process down into several smalller less complex tasks, the whole thing starts to feel easier.
Loading Libraries
We’ll start by loading the required libraries
import yaml
from jinja2 import Environment, FileSystemLoader, Template
Set the Environment
Essentially, this set’s the path which will define the directory where the templates will be loaded from. In this case, I’m setting it to load from the same directory.
ENV = Environment(loader=FileSystemLoader('./'))
Big Switch Networks is looking forward to a big 2016.
Monitoring, streamed telemetry, and scale are all on Arista's mind.
Carriers want their own flavors of MANO.