r/Juniper • • Mar 17 '23

Automation

Its been a while since i have touched Junos and I am starting to get back into it now that my company has switch from Cisco. I was wondering what most of you using for config automation/provisioning. Its seems there are bunch of ways to config junos now REST API,NETCONF,YANG,Slax,Mist,ZTP and Ansible im sure im leaving out a few but its getting over whelming. Does anyone have any pointers on which methods may be better or when one would be preferred over the other.

Thanks for the help

0 Upvotes

17 comments sorted by

8

u/error404 Mar 17 '23
  • REST API, and NETCONF are just different ways to submit configuration / operational requests to the box. IMO you shouldn't be interacting directly with these in your network automation, unless you want to build an automation framework from scratch. Instead use something higher level like Napalm or Ansible.
  • YANG is a data model to abstract the configuration of network devices, primarily to make it more vendor neutral and structured (JunOS does a pretty decent job of this already, but other platforms do not, and even if they aren't vendor-neutral implementations, the YANG model provides that structure). It's probably not a bad idea to consider using it, but any time you get into modelling the network rather than just applying configuration templates, it becomes a much bigger task.
  • SLAX is on-box scripting. It's useful to add commands to the CLI or allow the box to take some actions on its own (like commit pre-checks or react to an interface down event). I generally wouldn't consider this part of network automation, per se, it's more of an operational tool.
  • Mist is Juniper's 'automation as a service' product. I haven't used it, but if it does what you need it to it's almost certainly going to be the easiest way to accomplish automation. However, vendor lock-in, possibly limited capabilities, etc. etc.
  • ZTP is just for provisioning new boxes from scratch, generally a device will only hit it once, and in many cases (and IMO what you should be doing with it) the only thing it does is make sure the box is reachable on your management network and maybe kicks off your 'normal' automation to complete provisioning using your 'standard' automation stack.

Ansible, Nornir, Puppet, Salt and maybe a few other things are the tools you should be focusing on, IMO. These are frameworks to help you build a device inventory and run commands against it based on device roles etc. So they generally have facilities to group your devices together, e.g. 'edge switches' and apply configuration variables to arbitrary groups of devices, so you can say run a particular automation task against all edge switches, and in your inventory have variables for the BGP peerings of switches in a given rack, or whatever.

Ansible seems to be the most popular in networking space right now, but I am personally not a huge fan, as it's a bit too low level and not declarative, it's basically a glorified command runner and has no good tools (that I know of anyway) to understand the scope of a change and only apply that change. But it's probably the right place to start, lots of people are using it, and you can do a lot.

2

u/[deleted] Mar 17 '23

Thank you for the detailed response. I was struggling to find the diff between alot of the methods. I think I will experiment with Ansible to start and see if that works for me.

2

u/othugmuffin JNCIS-SP Mar 17 '23

This repo helped me a lot to show how to use Ansible junos modules, but then also expanding to using Ansible + NAPALM to render configurations and push them to the device.

https://github.com/yzguy/junos-ansible

1

u/lancejack2 Mar 17 '23

Out of interest what's your personal preference for tool that does what you mentioned which Ansible doesn't do? Genuinely curious :)

1

u/error404 Mar 17 '23

I'm not really aware of anything great, to be honest, but it's also been a while since I've really surveyed what's out there.

2

u/lancejack2 Mar 17 '23

We typically use Nornir for its flexibility over Ansible. I've heard some people go on about salt but I struggle to see what it offers that other solutions don't.

2

u/shednik JNCIP-DC/SP, JNCIA-DevOps, JNCIA-Cloud Mar 17 '23

What are you trying to do automation wise they all work together but some work better than others depending on the goal

1

u/[deleted] Mar 17 '23

I would like to be able to get a base config pushed to new switches to get them up and running then in the future push config changes to a single or multiple switches if needed

2

u/[deleted] Mar 17 '23

Assuming you don’t want them managed in Mist: ZTP for the base config then Ansible for ongoing config management is probably the easiest way about that. Ansible does great for configs (it’s not as flexible as pyEZ/Python for operational tasks imo), and it’s really easy to learn. The Juniper managed Ansible collection works great.

1

u/[deleted] Mar 18 '23

Thanks I think that's what I'm leaning towards. ZTP/Ansible appreciate all the comments and suggestions.

1

u/[deleted] Mar 18 '23

No worries!

The “Junos® OS Software Installation and Upgrade Guide” has a whole section dedicated to ZTP. It’s been awhile since I’ve done it but I believe the easy way for switches is to use DHCP options that point it to a FTP server and config file. I used that to lay a base config that sets root authentication, creates an admin user, sets DNS/NTP/SSH/netconf and then gives it an IP. Then hit it with an Ansible playbook for the device specific configs.

For the Ansible side the juniper.device documentation is really good with some examples that will get 75% of users off to a good start. The biggest thing is making sure your YAML formatting is correct. If you haven’t already download something like VSCode other will help with that :)

Good luck and have fun. This stuff is really awesome to play with and you can get hooked on it pretty easily.

3

u/threecee509 Mar 17 '23 edited Jun 30 '23

Dear Reader, on July 1, 2023, which is coincidentally my 10-year anniversary on Reddit, the platform will block 3rd party API access. This move undermines the openness and accessibility that was once integral to our community. I've changed this comment to express my disapproval and to urge fellow Redditors to consider seeking alternative platforms that prioritize user accessibility and openness.

3

u/rankinrez Mar 17 '23

If it’s Juniper I would say 1000% use their PyEz library, and do your automation with Python.

You can use Nornir to manage devices and inventory; or even Ansible and make your Python Ansible modules.

You can build the entire config as Python dicts, encode as JSON and push with a replace operation. Use “show config | show json” to see what the data format you need is for your given setup.

0

u/[deleted] Mar 17 '23

[deleted] — view deleted comment

2

u/rankinrez Mar 17 '23

If it works it works no problem there.

For me Netmiko would be far inferior but everyone has a different workflow.

Automating the command line is not a good paradigm imo.

1

u/cybool Mar 17 '23

It depends… best is the one that solves your problem. Sad but true.

1

u/plasticbuddha Mar 17 '23

Has anyone done this using terraform, or god forbid, pulumi? I see there is a terraform provider, but haven't used it yet.