Tools

Network automation playground

Runs in your browser. Nothing you enter is sent anywhere, and the page’s security policy stops it from contacting other sites.

Write a Jinja-style template, give it variables in YAML or JSON, and see the configuration it renders, one file per device. YAML is read as Ansible reads it, and filters such as ipaddr, selectattr and combine work as they do in Ansible.

Template

Variables

In an editor, Tab indents. To move on with the keyboard, press Esc, then Tab.

Options

Output

What the templates support

Rendering uses Nunjucks, which follows Jinja2 closely, with additions so that templates written for Ansible work as they are. It is not Python’s Jinja2, so check a template in your real pipeline before you rely on it.

Syntax

{{ }}, {% if %}, {% for %} withloop.index and a condition ({% for p in ports if p.up %}),{% set %}, {% macro %},{# comments #}, True, False, None, slices such as l[1:], x in list and tests such asis defined.

Python methods

Strings: upper, lower, strip, split,startswith, endswith, replace, join,zfill, ljust, rjust and more. Lists:append, extend, insert, pop,index. Dicts: items, keys, values,get, update.

Ansible filters

to_json, to_nice_json, from_json, to_yaml,to_nice_yaml, from_yaml, regex_replace,regex_search, regex_findall, ternary,mandatory, bool, combine, dict2items,items2dict, unique, flatten, map,selectattr, rejectattr, sum, min,max, and the tests match, search andregex.

Network filters

ipaddr with address, network, netmask,hostmask, wildcard, prefix, broadcast,size, network/prefix, host/prefix,network_wildcard, first_usable, last_usable,public, private or a number for the nth address; andipv4, ipv6, ipmath, nthhost andcidr_merge.

Variables

YAML is read as Ansible reads it: yes, no, on andoff are true or false, and <<: *anchor merge keys work. With “One file per device”, each item of the list renders separately, with the shared variables underneath its own and inventory_hostname set to its name.

Not supported yet

{% include %}, {% import %} and{% extends %}; x is in list (write x in list); a test's argument without parentheses (write x is divisibleby(3), not x is divisibleby 3); and undefined variables are only caught where they are printed, not inside{% if %}.

Templates and variables are rendered in your browser, in a separate worker that cannot reach the network. They are not sent anywhere or put in the address bar. “Remember on this device” keeps them in this browser only, until you clear them.