Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

New Lesson - Using Jinja for Config Templates #121

Merged
merged 26 commits into from
Nov 6, 2018

Conversation

ShrutiVPawaskar
Copy link
Contributor

@ShrutiVPawaskar ShrutiVPawaskar commented Oct 30, 2018

Introduction to Jinja2 and Junos PyEz

Part 1 – Intro to Jinja2

Discusses Jijna2 syntax

  • Template rendering
  • {% if %}
  • {% for %}
  • {% set %}

Part 2 – Into to PyEz

  • Connecting to a remote Junos device.
  • Getting configuration from the Junos device.
  • Loading configuration to the Junos device.

Part 3 –Configuring Junos Device using PyEz and Jinja2 Template

  • Creating Jinja2 template for Junos configuration.
  • Rendering Jinja2 template.
  • Pushing config to the Junos device using PyEz config module

Part 4 - Optimizing Configuration Push

  • Use Junos PyEz inbuilt function to render Jinja2 template and configure a single device
    with Config(dev, mode='private') as cu:
    cu.load(template=template, template_vars=template_vars, format='text')

Part 5 –Configuring multiple Junos devices using Jinja2 template

  • Use a single Jinja2 template
  • Use YAML file or Python dictionary as variables
  • Pushing basic config like hostname to multiple devices.

Closes nre-learning/antidote#72

@ShrutiVPawaskar ShrutiVPawaskar force-pushed the master branch 2 times, most recently from 0ea24eb to cbe95af Compare October 30, 2018 20:53
@shahbhoomi
Copy link
Contributor

@Mierdin Can you please review our lesson.

Copy link
Member

@Mierdin Mierdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start! I have a few comments, most of which are suggestions you can simply accept if you wish. Most of my other comments are structural or syntactic - for instance you're using italics instead of a code snippet. Generally my concerns are about consistency - if you're using a certain style in the beginning, such as the way you're referring to code snippets or examples, do that consistently across the lesson. I didn't get all the way through the PR - I stopped at lesson 3 because I didn't want to drown you with a billion comments on the same thing. Could you go back and try to apply those comments across the lesson as a whole? I think it will end up looking a lot better on the front-end.

Also - have you tested this out locally? The reason I ask is that the utility container doesn't currently have jinja installed. I am hoping you've instead tested this with your own image. In any case, the users will want to have access to jinja, so please add this to images/utility/requirements.txt in this PR.

Thanks to you both for your hard work on this - ping me here or on Slack for any questions.

CHANGELOG.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage1/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage1/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage1/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage1/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage2/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage2/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage2/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage3/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage3/guide.md Outdated Show resolved Hide resolved
@shahbhoomi
Copy link
Contributor

@Mierdin we have made the proposed changes in stage 1 and 2 and we also reviewed the stage 3 and stage 4. Could you please check it now?

@ShrutiVPawaskar
Copy link
Contributor Author

@Mierdin I have changed the syntax snippet to three-backticks (```) to and have renumbered the snippet accordingly.

Issue:

 Okay. Please use the three-backticks (```) here anyways so that it renders correctly - you don't have to put a button here. Note that the javascript for the run this snippet button still counts this so you'll have to update your indices for the other places you have this button appropriately.

@ShrutiVPawaskar
Copy link
Contributor Author

@Mierdin We have added a new stage in the lesson based on Jeremy's recommendation. Hence, moved parts around in other lessons.

@Mierdin Mierdin changed the title WIP Using Jinja for Config Templates New Lesson - Using Jinja for Config Templates Nov 6, 2018
Mierdin
Mierdin previously approved these changes Nov 6, 2018
Copy link
Member

@Mierdin Mierdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really good. Thanks for working on this - I imagine this will rapidly become one of the most popular lessons - I often blow network engineers' minds with what can be done with Jinja.

lessons/lesson-16/stage1/guide.md Outdated Show resolved Hide resolved
lessons/lesson-16/stage5/guide.md Show resolved Hide resolved
Co-Authored-By: ShrutiVPawaskar <[email protected]>
@ShrutiVPawaskar ShrutiVPawaskar dismissed stale reviews from Mierdin via 3e7d3ce November 6, 2018 00:35
@Mierdin Mierdin merged commit cce032f into nre-learning:master Nov 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants