Why Automate? Ansible Playbooks and Desired State for Network Operating Systems

Writing your own code isn’t always the answer

…but you still have a lot of work to do

Playbook Automation

Supporting Files

  • Don’t let names collide between production, lab, etc. We don’t want to have a Wargames scenario in anybody’s production network.
  • Make sure it makes sense. It’s pretty easy to over/under-organize; think about the smallest elemental unit you may work on.
  • Leverage Source Control! Save a copy, keep your revision history. Even better, get peer reviews.
  • Remember, this can be edited later! This should continually improve.

Inventory

  • YAML Inventory: This is just me, I prefer it over the INI format as a Linux guy. It also helps a lot with structured hierarchies, which I like as a network guy.
  • Variable declarations:
  • ansible_network_os: More or less does exactly what it says. There's a built-in ansible interpreter for VyOS - but this is really only true for a handful of network distros. You can get more from Ansible Galaxy, but extensive testing should be applied.
  • ansible_connection: This is basically the "driver" for the CLI. You can use Paramiko or SSH as well. this is primarily governed by your Network OS.
  • ansible_user just instructs the control node on what username to attempt against the target host.

The Playbooks

Values

  • Idempotency: Run once, get the same result every time. If a change already has been made and is invasive, don’t repeat it unless the state doesn’t match.
  • Thin Veil of Abstraction: You should be aware of what is being implemented from a technical perspective, but not have to control every last aspect of it.
  • Be Declarative: Try to design from the abstract concept you want to implement, and fill in the technical details as needed, not the other way around.

Day 0, get the system online

  • Load Variables: This will be a separate file, effectively designing the what of your deployment
  • Load Template, then translate variables: This will be executed by the template module
- hosts: localhost tasks: - name: Import Vars... include_vars: file: vyos-base.yml - name: Combine vyos... template: src: templates/vyos-base.j2 dest: vyos-compiled.conf

Day 2, apply routine changes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nick Schmidt

Nick Schmidt

4 Followers

I am a network engineer based out of Alaska, pursuing various methods of achieving SRE/NRE