diff options
Diffstat (limited to 'tools/netbox/scripts')
-rwxr-xr-x | tools/netbox/scripts/start-testenv.sh | 12 | ||||
-rwxr-xr-x | tools/netbox/scripts/testdata.tf | 96 | ||||
-rwxr-xr-x | tools/netbox/scripts/upload.sh | 25 |
3 files changed, 133 insertions, 0 deletions
diff --git a/tools/netbox/scripts/start-testenv.sh b/tools/netbox/scripts/start-testenv.sh new file mode 100755 index 0000000..011d2f5 --- /dev/null +++ b/tools/netbox/scripts/start-testenv.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +git clone -b release https://github.com/netbox-community/netbox-docker.git +cd netbox-docker +tee docker-compose.override.yml <<EOF +services: + netbox: + ports: + - 8000:8080 +EOF +docker compose pull +docker compose up
\ No newline at end of file diff --git a/tools/netbox/scripts/testdata.tf b/tools/netbox/scripts/testdata.tf new file mode 100755 index 0000000..42223d3 --- /dev/null +++ b/tools/netbox/scripts/testdata.tf @@ -0,0 +1,96 @@ +## +## EX2200 and EX3300 device types must be added +## +## +terraform { + required_providers { + netbox = { + source = "e-breuninger/netbox" + version = "~> 3.2.1" + } + } +} + +# example provider configuration for https://demo.netbox.dev +provider "netbox" { + server_url = "http://localhost:8000" + api_token = "14ef292da3c0564c591cd39eb22fa2cbab75b141" +} + +resource "netbox_manufacturer" "juniper" { + name = "Juniper" +} + +resource "netbox_site" "site" { + name = "Vikingskipet" +} + +resource "netbox_location" "loc" { + name = "Ringen" + site_id = netbox_site.site.id +} + +resource "netbox_device_role" "access" { + color_hex = "ff5722" + name = "Access switch" + slug = "access-switch" +} +resource "netbox_device_role" "leaf" { + color_hex = "ff5722" + name = "Leaf" + slug = "leaf" +} +resource "netbox_device_role" "distro" { + color_hex = "ff5722" + name = "Distro" + slug = "distro" +} +resource "netbox_device_role" "utskutt_distro" { + color_hex = "ff5722" + name = "Utskutt Distro" + slug = "utskutt-distro" +} + +resource "netbox_ipam_role" "clients" { + name = "Clients" +} + +resource "netbox_vrf" "clients" { + name = "CLIENTS" +} + +resource "netbox_vlan_group" "fabric" { + max_vid = 10 + min_vid = 400 + name = "client-vlans" + slug = "client-vlans" +} + +resource "netbox_vlan" "mgmt" { + name = "juniper-mgmt" + vid = 10 +} + +resource "netbox_prefix" "fabric_v4" { + prefix = "10.25.0.0/16" + status = "container" + description = "Fabric v4 clients" +} + +resource "netbox_prefix" "fabric_v6" { + prefix = "2a06:5844:e::/48" + status = "container" + description = "Fabric v6 clients" +} + +resource "netbox_prefix" "mgmt_v4" { + prefix = "185.110.149.0/25" + status = "active" + vlan_id = netbox_vlan.mgmt.id +} + +resource "netbox_prefix" "mgmt_v6" { + prefix = "2a06:5841:f::/64" + status = "active" + vlan_id = netbox_vlan.mgmt.id +} diff --git a/tools/netbox/scripts/upload.sh b/tools/netbox/scripts/upload.sh new file mode 100755 index 0000000..d5dc87e --- /dev/null +++ b/tools/netbox/scripts/upload.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +NETBOX_URL="https://netbox.tg25.tg.no/api/extras/scripts/" +API_TOKEN="4fcbbc0f5531d413470fe0aa98134da187eaaafe" +SCRIPT_PATH="create-switch/create-switch.py" + + +response=$(curl -s -w "\n%{http_code}" -X POST "$NETBOX_URL" \ + -H "Authorization: Token $API_TOKEN" \ + -H "Content-Type: multipart/form-data" \ + -F "script=@$SCRIPT_PATH" ) + +http_body=$(echo "$response" | sed '$d') +http_code=$(echo "$response" | tail -n1) + +echo "$response" + +# Check the response status code +if [ "$http_code" -eq 201 ]; then + echo "Custom script uploaded successfully!" +else + echo "Failed to upload custom script. HTTP status code: $http_code" + echo "Response from server: $http_body" + exit 1 +fi
\ No newline at end of file |