Building network automation solutions

9 module online course

Start now!

Custom Groups and Deployment Templates in netsim-tools

Using custom templates to test IP anycast with MPLS was fun, but as I got into interesting discussions focusing on convoluted details, I found myself going through the same set of steps too many times.

It started with the need to specify individual devices in netlab config command to create new loopback interfaces on anycast servers but not on any other device in the lab. Wouldn’t it be nice to have a group of devices (similar to Ansible groups) that one could use in the limit parameter of netlab config?

A few hours later1, I had them. netsim-tools now support custom device groups. Here’s the updated version of my lab topology file:

module: ospf

defaults:
  device: iosv

groups:
  anycast:
    members: [ a1, a2, a3 ]

nodes: [ l1, l2, l3, s1, a1, a2, a3 ]

links: [ s1-l1, s1-l2, s1-l3, l2-a1, l2-a2, l3-a3 ]

netlab create or netlab up automatically create additional groups in Ansible inventory, and I can use the anycast group to execute netlab config ospf-anycast-loopback.j2 --limit anycast.

Next: wouldn’t it be cool to deploy additional configuration templates during lab creation time? How about specifying them in the topology file? Like this…

module: ospf

defaults:
  device: iosv

groups:
  anycast:
    members: [ a1, a2, a3 ]
    config: [ ospf-anycast-loopback.j2 ]
  all:
    config: [ mpls-ldp.j2 ]

nodes: [ l1, l2, l3, s1, a1, a2, a3 ]

links: [ s1-l1, s1-l2, s1-l3, l2-a1, l2-a2, l3-a3 ]

When netlab up is executed, the ospf-anycast-loopback.j2 configuration template should be deployed on anycast devices to create additional loopback interfaces, and mpls-ldp.j2 template should be deployed on all lab devices to enable MPLS forwarding and LDP.

Another hour or two and I got it up and running. Now I can execute netlab up and get a fully functional anycast-with-MPLS lab in one go.

Finally, as I was getting annoyed by the clutter generated by the Ansible playbooks, I implemented the quiet flag in netlab up command. It sets ANSIBLE_STDOUT_CALLBACK to dense which really quiets down ansible-playbook.

The new functionality is already published on GitHub and on PyPi. Use pip3 install --upgrade netsim-tools if you already installed netsim-tools, or start with the installation guide if you’re a new user.


  1. Obviously it would be easier and faster to execute those commands by hand for the next five years, but this was more fun. ↩︎

1 comments:

  1. I don't think you meant Javascript "netlab config ospf-anycast-loopback.js --limit anycast" but Jinja2 instead ;)

    Replies
    1. Thank you. Fixed... although it WOULD be fun deploying JavaScript on network devices, wouldn't it?

Add comment
Sidebar