Refactor and modularize edgeconfig scripts
- Entirely new netbox helper functions, using pynetbox and objects,
instead of previous spaghetti code
- Allow for VM interfaces
- Allow device names to specify more than one segment of the DNS subdomain
- Split out forward and reverse DNS
- Fix issues with DHCP zone creation
- Support advertising NTP server via DHCP option
Playbooks
- Add QA, router, DNS, and user creation/config playbook
- Fix YAML formatting issues with playbooks
Change-Id: Id6c010ef1e122f4fd1bd97e9bb2128c4271947d0
diff --git a/scripts/edgeconfig.py b/scripts/edgeconfig.py
new file mode 100644
index 0000000..5dc21fc
--- /dev/null
+++ b/scripts/edgeconfig.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+# edgeconfig.py
+# Given a yaml config file (same as ansible inventory for a site), create a
+# YAML file consumable by ansible as variables that configures the managmeent
+# node for that site
+
+from __future__ import absolute_import
+
+import argparse
+import nbhelper
+import json
+import os
+import pprint
+
+from ruamel import yaml
+
+# main function that calls other functions
+if __name__ == "__main__":
+
+ # this is passed to argparse, key is option name, rest is kwargs
+ extra_args = {
+ "base_config": {
+ "default": os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), "base_edgeconfig.yaml"
+ ),
+ "nargs": "?",
+ "type": argparse.FileType("r"),
+ "help": "Config (optional, default: base_edgeconfig.yaml)",
+ },
+ }
+
+ args = nbhelper.parse_cli_args(extra_args)
+ nbh = nbhelper.NBHelper(args)
+
+ # use base_config for additional items
+ yaml_out = yaml.safe_load(args.base_config.read())
+
+ dhcpd_subnets = []
+ dhcpd_interfaces = []
+
+ # reverse zones aggregate across RFC1918 IP prefix
+ dns_reverse_zones = nbhelper.NBDNSReverseZones()
+
+ for prefix in nbh.all_prefixes():
+
+ nbhelper.NBDNSForwardZone.get_fwd_zone(prefix)
+
+ dns_reverse_zones.add_prefix(prefix)
+
+ dhcpd_subnet = nbhelper.NBDHCPSubnet(prefix)
+
+ dhcpd_if = dhcpd_subnet.dhcpd_interface
+
+ if dhcpd_if and dhcpd_if not in dhcpd_interfaces:
+ dhcpd_interfaces.append(dhcpd_if)
+
+ dhcpd_subnets.append(dhcpd_subnet)
+
+ # yaml_out["devices"] = nbhelper.NBDevice.all_devs()
+ yaml_out["dns_forward_zones"] = nbhelper.NBDNSForwardZone.all_fwd_zones()
+ yaml_out["dns_reverse_zones"] = dns_reverse_zones
+ yaml_out["dhcpd_subnets"] = dhcpd_subnets
+ yaml_out["dhcpd_interfaces"] = dhcpd_interfaces
+
+ print(yaml.safe_dump(yaml_out, indent=2))