diff --git a/ansible/roles/blade.opengear/action_plugins/opengear_sync.py b/ansible/roles/blade.opengear/action_plugins/opengear_sync.py index 3381e10..3ba8a70 100644 --- a/ansible/roles/blade.opengear/action_plugins/opengear_sync.py +++ b/ansible/roles/blade.opengear/action_plugins/opengear_sync.py @@ -36,7 +36,7 @@ class ActionModule(ActionBase): d = d.split(" ")[0] d = d.split(".") assert d[0] == "config" - if d[1] in ["ports", "ntp","users"]: + if d[1] in ["ports", "ntp", "users"]: whitelist.append(f"config.{d[1]}.") elif len(d) > 3: whitelist.append(".".join(d[:3]) + ".") diff --git a/data/os/opengear/topology.yaml b/data/os/opengear/topology.yaml index f874538..15d98b4 100644 --- a/data/os/opengear/topology.yaml +++ b/data/os/opengear/topology.yaml @@ -1,2 +1,2 @@ addresses: - main: "~{{ lookup('topology','interfaces').wan.address }}" + main: "~{{ lookup('topology', 'interfaces').wan.address }}" diff --git a/searchpaths.py b/searchpaths.py index e6a056d..55d5f91 100644 --- a/searchpaths.py +++ b/searchpaths.py @@ -5,7 +5,7 @@ def searchpaths(scope): ['host/titi', 'common'] >>> searchpaths(dict(host="titi.sk1", shorthost="titi", location="sk1")) ['host/titi.sk1', 'host/sk1/titi', 'groups/sk1', 'common'] - >>> searchpaths(dict(groups=["tor","tor-bgp"], location="sk1", continent="oc")) + >>> searchpaths(dict(groups=["tor", "tor-bgp"], location="sk1", continent="oc")) ['groups/tor-bgp-sk1', 'groups/tor-sk1', 'groups/tor-bgp-oc', 'groups/tor-oc', 'groups/tor-bgp', 'groups/tor', 'groups/sk1', 'common'] """ paths = [ diff --git a/templates/junos/edge-bgp.j2 b/templates/junos/edge-bgp.j2 index 9fee285..45c70a1 100644 --- a/templates/junos/edge-bgp.j2 +++ b/templates/junos/edge-bgp.j2 @@ -241,7 +241,7 @@ policy-options { route-filter-list DEFAULT-V6 ::0/0 exact; route-filter-list TOO-SPECIFIC-V4 0.0.0.0/0 prefix-length-range /25-/32; route-filter-list TOO-SPECIFIC-V6 ::/0 prefix-length-range /49-/128; -{% set supernets = lookup("bgp","supernets") or {} %} +{% set supernets = lookup("bgp", "supernets") or {} %} {% set man = lookup("topology", "man") %} {% for edge in devices("environment", "groups==edge") if scope(edge).location == location or (man and lookup("topology", "man", edge) == man) %} diff --git a/templates/junos/edge-fabric.j2 b/templates/junos/edge-fabric.j2 index c235c9b..ea596bf 100644 --- a/templates/junos/edge-fabric.j2 +++ b/templates/junos/edge-fabric.j2 @@ -1,7 +1,7 @@ routing-instances internet { protocols { bgp { -{% set sspines = devices("environment","location","groups==sspine-bgp") %} +{% set sspines = devices("environment", "location", "groups==sspine-bgp") %} {% for sspine in sspines %} {% for port, device in lookup("topology", "ports", sspine).items() if device == shorthost %} {% for interface, infos in lookup("topology", "interfaces").items() if infos.remote is defined and "{}.{}.blade-group.net".format(infos.remote, location) == sspine %} diff --git a/templates/junos/edge-interfaces.j2 b/templates/junos/edge-interfaces.j2 index 12339ea..c88011a 100644 --- a/templates/junos/edge-interfaces.j2 +++ b/templates/junos/edge-interfaces.j2 @@ -96,7 +96,7 @@ routing-instances { } {% endif %} -{% set sspines = devices("environment","location","groups==sspine-bgp") %} +{% set sspines = devices("environment", "location", "groups==sspine-bgp") %} {% for sspine in sspines %} {% for port, device in lookup("topology", "ports", sspine).items() if device == shorthost %} {% for interface, infos in lookup("topology", "interfaces").items() if infos.remote is defined and "{}.{}.blade-group.net".format(infos.remote, location) == sspine %} diff --git a/templates/junos/edge-sampling.j2 b/templates/junos/edge-sampling.j2 index 70b90e0..0142d5e 100644 --- a/templates/junos/edge-sampling.j2 +++ b/templates/junos/edge-sampling.j2 @@ -30,7 +30,7 @@ groups { services { flow-monitoring { version-ipfix { - {% for version in ("ipv4","ipv6") %} + {% for version in ("ipv4", "ipv6") %} template {{ version }} { flow-active-timeout 10; flow-inactive-timeout 10; @@ -57,7 +57,7 @@ forwarding-options { max-packets-per-second 65535; } - {% for version in ("ipv4","ipv6") %} + {% for version in ("ipv4", "ipv6") %} family {{ "inet" if version == "ipv4" else "inet6" }} { output { flow-server {{ lookup('system', 'sampling').target }}{ @@ -128,7 +128,7 @@ protocols { {% do ifd_list.append(ifd) %} {% endif %} {% endfor %} -{% set sspines = devices("environment","location","groups==sspine-bgp") %} +{% set sspines = devices("environment", "location", "groups==sspine-bgp") %} {% for sspine in sspines %} {% for port, device in lookup("topology", "ports", sspine).items() if device == shorthost %} {% for interface, infos in lookup("topology", "interfaces").items() if infos.remote is defined and "{}.{}.blade-group.net".format(infos.remote, location) == sspine %} diff --git a/templates/junos/firewall.j2 b/templates/junos/firewall.j2 index 1962e4e..1c97340 100644 --- a/templates/junos/firewall.j2 +++ b/templates/junos/firewall.j2 @@ -97,7 +97,7 @@ policy-options { {% set filter = 'accept-bgp' %} {% do ipv4_filter_list.append("ipv4-{}".format(filter)) %} {% do ipv6_filter_list.append("ipv6-{}".format(filter)) %} - {% for ipv in ["ipv4","ipv6"] %} + {% for ipv in ["ipv4", "ipv6"] %} firewall { family {{"inet" if ipv=="ipv4" else "inet6"}} { filter {{ ipv }}-{{ filter }} { diff --git a/templates/linux/adm-gateway/nftables-rules.j2 b/templates/linux/adm-gateway/nftables-rules.j2 index 878c96f..c14cb6f 100644 --- a/templates/linux/adm-gateway/nftables-rules.j2 +++ b/templates/linux/adm-gateway/nftables-rules.j2 @@ -61,7 +61,7 @@ table ip blade { map specific-ip-tcp-map { type ipv4_addr . inet_service : verdict elements = { - {% for other in devices("environment", "location", "groups==adm-gateway-l3") if device != other %} + {% for other in devices("environment", "location", "groups==adm-gateway") if device != other %} {{ lookup("topology", "addresses", other).main }} . 647 : accept, {% endfor %} {{ addresses.prometheus }} . 9100 : accept, diff --git a/templates/linux/conserver.j2 b/templates/linux/conserver.j2 index 1895c91..13bfcd4 100644 --- a/templates/linux/conserver.j2 +++ b/templates/linux/conserver.j2 @@ -26,7 +26,7 @@ default {{ device }} { host {{ device }}; } - {% for port,remote in lookup("topology","ports",device).items() %} + {% for port,remote in lookup("topology", "ports",device).items() %} console {{ remote }} { include {{ device }} ;port {{ port }}; } {% if "." in remote and remote not in alreadyseen %} {#- Create short host in case of dual re/fpc #} {% set remote= remote.split(".")[1] %} diff --git a/templates/none/dns.j2 b/templates/none/dns.j2 index a10e065..88b3656 100644 --- a/templates/none/dns.j2 +++ b/templates/none/dns.j2 @@ -30,7 +30,7 @@ zones: {# Collect all DNS registered through the datastore #} entries: {% for device, ip, interface in store("addresses") %} - {% set name = "{}.{}".format(interface|replace(".", "-")|replace("/", "-")|replace(":","-")|lower, device) %} + {% set name = "{}.{}".format(interface|replace(".", "-")|replace("/", "-")|replace(":", "-")|lower, device) %} {% if ip|ipaddr("public") %} {% set name = name|replace(".blade-group.net", ".shadow.guru") %} {% endif %} diff --git a/templates/opengear/config.j2 b/templates/opengear/config.j2 index 2a8654c..e43ca75 100644 --- a/templates/opengear/config.j2 +++ b/templates/opengear/config.j2 @@ -60,7 +60,7 @@ config.{{ interface }}.services.snmp.enabled on config.{{ interface }}.services.ssh.enabled on config.{{ interface }}.services.ssh_ports.enabled on config.{{ interface }}.services.tcp_ports.enabled on - + {% endif %} {% endfor %} @@ -71,8 +71,8 @@ config.dialin.services.modified true config.dialout.services.modified true ## console ports -{% for port,device in lookup("topology","ports").items() %} -{% set custom_param = lookup("system","console","{}.{}.blade-group.net".format(device,location)) %} +{% for port,device in lookup("topology", "ports").items() %} +{% set custom_param = lookup("system", "console", "{}.{}.blade-group.net".format(device,location)) %} config.ports.port{{ port }}.charsize 8 config.ports.port{{ port }}.dtrmode alwayson @@ -100,7 +100,7 @@ config.services.lldp.enabled on config.services.snmp.enabled on config.services.snmp.protocol UDP config.services.snmp.roauthprotocol SHA -config.services.snmp.rocommunity {{ lookup("system","snmp")["ro-community"] }} +config.services.snmp.rocommunity {{ lookup("system", "snmp")["ro-community"] }} config.services.snmp.roprivprotocol DES config.services.snmp.syscontact someone@example.com config.services.snmp.syslocation {{ lookup("system", "datacenter") }}, {{ lookup("system", "country") }} @@ -117,5 +117,5 @@ config.system.timezone UTC ## user config.users.user1.description Root User config.users.user1.username root -config.users.user1.password {{ lookup("system","users").blade["opengear-password"] }} +config.users.user1.password {{ lookup("system", "users").blade["opengear-password"] }} config.users.total 1 diff --git a/templates/opengear/motd.j2 b/templates/opengear/motd.j2 index 5a385a8..ebbe5bf 100644 --- a/templates/opengear/motd.j2 +++ b/templates/opengear/motd.j2 @@ -1 +1 @@ -{{ lookup("system","motd") }} +{{ lookup("system", "motd") }}