diff --git a/custom-objects-quickstart/2_start_netbox.sh b/custom-objects-quickstart/2_start_netbox.sh index 9c71ac1..9bb5cfb 100755 --- a/custom-objects-quickstart/2_start_netbox.sh +++ b/custom-objects-quickstart/2_start_netbox.sh @@ -27,7 +27,8 @@ echo cat < Dockerfile-Plugins FROM netboxcommunity/netbox:v4.4.0 -RUN uv pip install netboxlabs-netbox-custom-objects +RUN uv pip install netboxlabs-netbox-custom-objects==0.3.1 + EOF cat < docker-compose.override.yml @@ -47,10 +48,13 @@ services: SUPERUSER_NAME: "admin" SUPERUSER_PASSWORD: "admin" healthcheck: - test: curl -f http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/login/ || exit 1 - start_period: 600s + test: curl -f http://127.0.0.1:8080/login/ || exit 1 + start_period: 100s timeout: 3s interval: 15s + postgres: + ports: + - "5432:5432" netbox-worker: image: netbox:v4.4.0-plugins pull_policy: never diff --git a/netbox-discovery-quickstart/1_set_envvars.sh b/netbox-discovery-quickstart/1_set_envvars.sh index 0d658a2..3aa0277 100755 --- a/netbox-discovery-quickstart/1_set_envvars.sh +++ b/netbox-discovery-quickstart/1_set_envvars.sh @@ -2,15 +2,6 @@ ENV_FILE="environment" -# Function to generate random keys -generate_random_key() { - head -c20 "$ENV_FILE" @@ -45,10 +32,6 @@ MY_EXTERNAL_IP=$MY_EXTERNAL_IP NETBOX_PORT=$NETBOX_PORT DOCKER_SUBNET=$DOCKER_SUBNET DOCKER_NETWORK=$DOCKER_NETWORK -DIODE_TO_NETBOX_API_KEY=$DIODE_TO_NETBOX_API_KEY -NETBOX_TO_DIODE_API_KEY=$NETBOX_TO_DIODE_API_KEY -DIODE_API_KEY=$DIODE_API_KEY -INGESTER_TO_RECONCILER_API_KEY=$INGESTER_TO_RECONCILER_API_KEY EOF fi @@ -64,8 +47,4 @@ echo "External IP: $MY_EXTERNAL_IP" echo "NetBox will be deployed at: http://$MY_EXTERNAL_IP:$NETBOX_PORT" echo "Docker subnet: $DOCKER_SUBNET" echo "Docker network: $DOCKER_NETWORK" -echo "DIODE_TO_NETBOX_API_KEY: $DIODE_TO_NETBOX_API_KEY" -echo "NETBOX_TO_DIODE_API_KEY: $NETBOX_TO_DIODE_API_KEY" -echo "DIODE_API_KEY: $DIODE_API_KEY" -echo "INGESTER_TO_RECONCILER_API_KEY: $INGESTER_TO_RECONCILER_API_KEY" echo "-----------------------------------" diff --git a/netbox-discovery-quickstart/2_start_diode.sh b/netbox-discovery-quickstart/2_start_diode.sh new file mode 100755 index 0000000..66c3bee --- /dev/null +++ b/netbox-discovery-quickstart/2_start_diode.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Detect OS (macOS vs Linux) +OS_TYPE=$(uname) + +# Ensure required environment variables are set +REQUIRED_VARS=("MY_EXTERNAL_IP" "NETBOX_PORT") + +for var in "${REQUIRED_VARS[@]}"; do + if [ -z "${!var:-}" ]; then + echo "Error: Required environment variable '$var' is not set." + exit 1 + fi +done + +mkdir -p diode +pushd diode + +echo +echo "--- Downloading and preparing quickstart script ---" +echo + +curl -sSfLo quickstart.sh https://raw.githubusercontent.com/netboxlabs/diode/release/diode-server/docker/scripts/quickstart.sh +chmod +x quickstart.sh + +echo +echo "--- Running quickstart script pointing at NetBox at http://${MY_EXTERNAL_IP}:${NETBOX_PORT} ---" +echo + +./quickstart.sh "http://${MY_EXTERNAL_IP}:${NETBOX_PORT}" + +echo +echo "--- Bringing up Diode ---" +echo + +docker compose up -d + +echo +echo "--- Setting up netbox-to-diode client secret ---" +echo + +echo "To set up NetBox integration, run this command:" +echo "export NETBOX_TO_DIODE_CLIENT_SECRET=\$(jq -r '.[] | select(.client_id == \"netbox-to-diode\") | .client_secret' ./diode/oauth2/client/client-credentials.json)" + +# End +popd \ No newline at end of file diff --git a/netbox-discovery-quickstart/2_start_netbox.sh b/netbox-discovery-quickstart/2_start_netbox.sh deleted file mode 100755 index 7c92962..0000000 --- a/netbox-discovery-quickstart/2_start_netbox.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Check if all required environment variables are set -REQUIRED_VARS=("MY_EXTERNAL_IP" "NETBOX_PORT" "DIODE_TO_NETBOX_API_KEY" "NETBOX_TO_DIODE_API_KEY" "DIODE_API_KEY" "INGESTER_TO_RECONCILER_API_KEY") - -for var in "${REQUIRED_VARS[@]}"; do - if [ -z "${!var:-}" ]; then - echo "Error: Required environment variable '$var' is not set." - exit 1 - fi -done - -echo -echo "--- Cloning NetBox Docker ---" -echo - -# Clone netbox-docker -git clone --branch 3.0.2 https://github.com/netbox-community/netbox-docker.git -pushd netbox-docker - -echo -echo "--- Generating configuration files ---" -echo - -# Create plugin files -cat < plugin_requirements.txt -netboxlabs-diode-netbox-plugin -EOF - -cat < Dockerfile-Plugins -FROM netboxcommunity/netbox:v4.1-3.0.2 - -COPY ./plugin_requirements.txt /opt/netbox/ -RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /opt/netbox/plugin_requirements.txt -EOF - -cat < docker-compose.override.yml -services: - netbox: - image: netbox:v4.1-3.0.2-plugins - pull_policy: never - ports: - - "\${NETBOX_PORT}:8080" - build: - context: . - dockerfile: Dockerfile-Plugins - environment: - SKIP_SUPERUSER: "false" - SUPERUSER_API_TOKEN: "1234567890" - SUPERUSER_EMAIL: "" - SUPERUSER_NAME: "admin" - SUPERUSER_PASSWORD: "admin" - DIODE_TO_NETBOX_API_KEY: "\${DIODE_TO_NETBOX_API_KEY}" - NETBOX_TO_DIODE_API_KEY: "\${NETBOX_TO_DIODE_API_KEY}" - DIODE_API_KEY: "\${DIODE_API_KEY}" - #INGESTER_TO_RECONCILER_API_KEY: "\${INGESTER_TO_RECONCILER_API_KEY}" - healthcheck: - test: curl -f http://\${MY_EXTERNAL_IP}:\${NETBOX_PORT}/login/ || exit 1 - start_period: 600s - timeout: 3s - interval: 15s - netbox-worker: - image: netbox:v4.1-3.0.2-plugins - pull_policy: never - netbox-housekeeping: - image: netbox:v4.1-3.0.2-plugins - pull_policy: never -EOF - -# Add the Diode plugin and its configuration to configuration.py -cat < configuration/plugins.py -PLUGINS = ["netbox_diode_plugin"] - -PLUGINS_CONFIG = { - "netbox_diode_plugin": { - "auto_provision_users": False, - "diode_target_override": "grpc://${MY_EXTERNAL_IP}:8080/diode", - "diode_to_netbox_username": "diode-to-netbox", - "netbox_to_diode_username": "netbox-to-diode", - "diode_username": "diode-ingestion", - }, -} -EOF - -# Detect OS and apply sed command accordingly -OS_TYPE=$(uname) -if [[ "$OS_TYPE" == "Darwin" ]]; then - # macOS (requires '' for in-place edit) - sed -i '' "s|http://localhost:8080/login/|http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/login/|" docker-compose.yml -else - # Linux - sed -i "s|http://localhost:8080/login/|http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/login/|" docker-compose.yml -fi - -echo -echo "--- Building NetBox ---" -echo - -docker compose build --no-cache - -echo -echo "--- Starting NetBox Docker ---" -echo - -docker compose up -d - -# End -popd -echo "You can now access NetBox here: http://${MY_EXTERNAL_IP}:${NETBOX_PORT}" -echo "username: admin" -echo "password: admin" \ No newline at end of file diff --git a/netbox-discovery-quickstart/3_start_diode.sh b/netbox-discovery-quickstart/3_start_diode.sh deleted file mode 100755 index c7fcb15..0000000 --- a/netbox-discovery-quickstart/3_start_diode.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Detect OS (macOS vs Linux) -OS_TYPE=$(uname) - -# Ensure required environment variables are set -REQUIRED_VARS=("MY_EXTERNAL_IP" "NETBOX_PORT" "DIODE_TO_NETBOX_API_KEY" "DIODE_API_KEY" "NETBOX_TO_DIODE_API_KEY" "INGESTER_TO_RECONCILER_API_KEY") - -for var in "${REQUIRED_VARS[@]}"; do - if [ -z "${!var:-}" ]; then - echo "Error: Required environment variable '$var' is not set." - exit 1 - fi -done - -mkdir -p diode -pushd diode - -echo -echo "--- Fetching Diode docker-compose and .env files ---" -echo - -curl -o docker-compose.yaml https://raw.githubusercontent.com/netboxlabs/diode/release/diode-server/docker/docker-compose.yaml -curl -o .env https://raw.githubusercontent.com/netboxlabs/diode/release/diode-server/docker/sample.env - -echo -echo "--- Updating Diode .env file ---" -echo - -# Set correct sed syntax based on OS -if [[ "$OS_TYPE" == "Darwin" ]]; then - SED_CMD="sed -i ''" -else - SED_CMD="sed -i" -fi - -$SED_CMD "s|\(NETBOX_DIODE_PLUGIN_API_BASE_URL=http://\).*|\1${MY_EXTERNAL_IP}:${NETBOX_PORT}/api/plugins/diode|" .env -$SED_CMD "s|^\(DIODE_TO_NETBOX_API_KEY=\).*|\1${DIODE_TO_NETBOX_API_KEY}|" .env -$SED_CMD "s|^\(DIODE_API_KEY=\).*|\1${DIODE_API_KEY}|" .env -$SED_CMD "s|^\(NETBOX_TO_DIODE_API_KEY=\).*|\1${NETBOX_TO_DIODE_API_KEY}|" .env -$SED_CMD "s|^\(INGESTER_TO_RECONCILER_API_KEY=\).*|\1${INGESTER_TO_RECONCILER_API_KEY}|" .env - -cat .env - -echo -echo "--- Starting Diode ---" -echo - -docker compose up -d - -# End -popd \ No newline at end of file diff --git a/netbox-discovery-quickstart/3_start_netbox.sh b/netbox-discovery-quickstart/3_start_netbox.sh new file mode 100755 index 0000000..0201367 --- /dev/null +++ b/netbox-discovery-quickstart/3_start_netbox.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Check if all required environment variables are set +REQUIRED_VARS=("MY_EXTERNAL_IP" "NETBOX_PORT" "NETBOX_TO_DIODE_CLIENT_SECRET") + +for var in "${REQUIRED_VARS[@]}"; do + if [ -z "${!var:-}" ]; then + echo "Error: Required environment variable '$var' is not set." + exit 1 + fi +done + +echo +echo "--- Cloning NetBox Docker ---" +echo + +# Clone netbox-docker +git clone --branch 3.3.0 https://github.com/netbox-community/netbox-docker.git +pushd netbox-docker + +echo +echo "--- Generating configuration files ---" +echo + +cat < Dockerfile-Plugins +FROM netboxcommunity/netbox:v4.3.7 + +RUN uv pip install netboxlabs-diode-netbox-plugin +EOF + +cat < docker-compose.override.yml +services: + netbox: + image: netbox:v4.3.7-plugins + pull_policy: never + ports: + - "${NETBOX_PORT}:8080" + build: + context: . + dockerfile: Dockerfile-Plugins + environment: + SKIP_SUPERUSER: "false" + SUPERUSER_API_TOKEN: "1234567890" + SUPERUSER_EMAIL: "" + SUPERUSER_NAME: "admin" + SUPERUSER_PASSWORD: "admin" + healthcheck: + test: curl -f http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/login/ || exit 1 + start_period: 600s + timeout: 3s + interval: 15s + netbox-worker: + image: netbox:v4.3.7-plugins + pull_policy: never + netbox-housekeeping: + image: netbox:v4.3.7-plugins + pull_policy: never +EOF + +# Add the Diode plugin and its configuration to configuration.py +cat < configuration/plugins.py +PLUGINS = ["netbox_diode_plugin"] + +PLUGINS_CONFIG = { + "netbox_diode_plugin": { + # Diode gRPC target for communication with Diode server + "diode_target_override": "grpc://${MY_EXTERNAL_IP}:8080/diode", + # NetBox username associated with changes applied via plugin + "diode_username": "diode", + # netbox-to-diode client secret from earlier step + "netbox_to_diode_client_secret": "${NETBOX_TO_DIODE_CLIENT_SECRET}" + }, +} +EOF + +echo +echo "--- Building NetBox ---" +echo + +docker compose build --no-cache + +echo +echo "--- Starting NetBox Docker ---" +echo + +docker compose up -d + +# End +popd +echo "You can now access NetBox here: http://${MY_EXTERNAL_IP}:${NETBOX_PORT}" +echo "username: admin" +echo "password: admin" \ No newline at end of file diff --git a/netbox-discovery-quickstart/4_start_network.sh b/netbox-discovery-quickstart/4_start_network.sh index 443aaeb..17fc7ec 100755 --- a/netbox-discovery-quickstart/4_start_network.sh +++ b/netbox-discovery-quickstart/4_start_network.sh @@ -17,7 +17,7 @@ fi # Check if directory parameter is passed if [ $# -eq 0 ]; then - echo "Usage: $0 " + echo "Usage: $0 /.clab.yml" exit 1 fi @@ -48,4 +48,4 @@ echo echo "--- Starting network from '$CLAB_FILE' ---" echo -sudo clab deploy --topo "$CLAB_FILE" "${@:2}" \ No newline at end of file +sudo clab deploy --topo "$CLAB_FILE" "${@:2}" diff --git a/netbox-discovery-quickstart/5_start_network_discovery.sh b/netbox-discovery-quickstart/5_start_network_discovery.sh index 4aa1210..4132322 100755 --- a/netbox-discovery-quickstart/5_start_network_discovery.sh +++ b/netbox-discovery-quickstart/5_start_network_discovery.sh @@ -2,7 +2,7 @@ set -euo pipefail # Check if all required environment variables are set -REQUIRED_VARS=("MY_EXTERNAL_IP" "DOCKER_SUBNET" "DOCKER_NETWORK" "NETBOX_PORT" "DIODE_API_KEY") +REQUIRED_VARS=("MY_EXTERNAL_IP" "DOCKER_SUBNET" "DOCKER_NETWORK" "NETBOX_PORT" "DIODE_CLIENT_ID" "DIODE_CLIENT_SECRET") for var in "${REQUIRED_VARS[@]}"; do if [ -z "${!var:-}" ]; then @@ -33,13 +33,15 @@ orb: common: diode: target: grpc://${MY_EXTERNAL_IP}:8080/diode - api_key: ${DIODE_API_KEY} + client_id: ${DIODE_CLIENT_ID} + client_secret: ${DIODE_CLIENT_SECRET} agent_name: agent1 policies: network_discovery: - policy_1: + loopback_policy: + config: scope: - targets: + targets: - ${DOCKER_SUBNET} EOF @@ -50,11 +52,12 @@ echo "--- Start the agent ---" echo docker run -v $(pwd):/opt/orb/ \ - -e DIODE_API_KEY=${DIODE_API_KEY} \ + -e DIODE_CLIENT_ID=${DIODE_CLIENT_ID} \ + -e DIODE_CLIENT_SECRET=${DIODE_CLIENT_SECRET} \ --network ${DOCKER_NETWORK} \ netboxlabs/orb-agent:latest run -c /opt/orb/agent.yaml # End popd -echo "Now go and check the NetBox Discovery ingestion logs: http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/plugins/diode/ingestion-logs/" \ No newline at end of file +echo "Now go and check the discovered IPs in NetBox: http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/ipam/ip-addresses/" \ No newline at end of file diff --git a/netbox-discovery-quickstart/6_start_device_discovery.sh b/netbox-discovery-quickstart/6_start_device_discovery.sh index 10c2b98..fac3a4b 100755 --- a/netbox-discovery-quickstart/6_start_device_discovery.sh +++ b/netbox-discovery-quickstart/6_start_device_discovery.sh @@ -2,7 +2,7 @@ set -euo pipefail # Check if all required environment variables are set -REQUIRED_VARS=("MY_EXTERNAL_IP" "DOCKER_SUBNET" "NETBOX_PORT" "DIODE_API_KEY") +REQUIRED_VARS=("MY_EXTERNAL_IP" "DOCKER_SUBNET" "DOCKER_NETWORK" "NETBOX_PORT" "DIODE_CLIENT_ID" "DIODE_CLIENT_SECRET") for var in "${REQUIRED_VARS[@]}"; do if [ -z "${!var:-}" ]; then @@ -33,8 +33,9 @@ orb: common: diode: target: grpc://${MY_EXTERNAL_IP}:8080/diode - api_key: ${DIODE_API_KEY} - agent_name: agent1 + client_id: ${DIODE_CLIENT_ID} + client_secret: ${DIODE_CLIENT_SECRET} + agent_name: agent2 policies: device_discovery: discovery_1: @@ -72,10 +73,13 @@ echo "--- Starting agent ---" echo docker run -v $(pwd):/opt/orb/ \ - -e DIODE_API_KEY=${DIODE_API_KEY} \ + -e DIODE_CLIENT_ID=${DIODE_CLIENT_ID} \ + -e DIODE_CLIENT_SECRET=${DIODE_CLIENT_SECRET} \ -e INSTALL_DRIVERS_PATH=/opt/orb/drivers.txt \ --network ${DOCKER_NETWORK} \ netboxlabs/orb-agent:latest run -c /opt/orb/agent.yaml # End -popd \ No newline at end of file +popd + +echo "Now go and check the disocvered device details in NetBox: http://${MY_EXTERNAL_IP}:${NETBOX_PORT}/dcim/devices/" \ No newline at end of file diff --git a/netbox-discovery-quickstart/README.md b/netbox-discovery-quickstart/README.md index f7e18c4..38ef902 100644 --- a/netbox-discovery-quickstart/README.md +++ b/netbox-discovery-quickstart/README.md @@ -21,14 +21,18 @@ You will be able to run simple scripts to use both features of NetBox Discovery: > [!TIP] > -> - The workshop can be ran on a server or virtual machine with a public or private ip. Please see the additional step for the latter option +> - The workshop can be run on a server or virtual machine with a public or private IP. Please see the additional step for private IP options below. > - We recommend using a machine with at least 4GB of RAM and 2 cores. If you're using a discount cloud or are going to run Cisco IOS images, we recommend at least 8GB of RAM and 4 cores. -> - The workshop has only been tested on Ubuntu 22.04. It _should_ work on other Linux distros but if you hit any problems please create an [issue](https://github.com/netboxlabs/netbox-learning/issues) in GitHub -> - Unfortunately MacOS is not supported. The workshop relies heavily on ContainerLab which does not have native support for MacOS +> - The workshop has been tested on Ubuntu up to 25.04 (Plucky Puffin). It _should_ work on other Linux distros but if you hit any problems please create an [issue](https://github.com/netboxlabs/netbox-learning/issues) in GitHub +> - Unfortunately MacOS is not supported. The quickstart relies heavily on ContainerLab which does not have native support for MacOS ### Clone the repo and go to the Discovery Quickstart +> [!TIP] +> +> If you're using this on a fork, be sure to update the git repo URL accordingly + ``` cd /opt git clone https://github.com/netboxlabs/netbox-learning.git @@ -55,10 +59,10 @@ su - quickstart Optionally set a private IP. If this machine does not have a public ipv4 address assigned on a local interface, this option should be used. - Replace with an ip address assigned to the local machine - eg: 10.1.1.1 + Replace with an IP address assigned to the local machine - eg: `10.1.1.1` (**NOTE:** Do not use `127.0.0.1`/`localhost` as it will cause the NetBox healthcheck to fail and connections to get stuck in containers) ``` -export MY_EXTERNAL_IP= +export MY_EXTERNAL_IP= ``` > [!TIP] @@ -71,6 +75,16 @@ export MY_EXTERNAL_IP= source 1_set_envvars.sh ``` +### Start Diode. + +``` +./2_start_diode.sh +``` + +> [!TIP] +> Once Diode has finished installing be sure to follow the instructions to export the `NETBOX_TO_DIODE_CLIENT_SECRET` as it is required when starting NetBox. +> `export NETBOX_TO_DIODE_CLIENT_SECRET=$(jq -r '.[] | select(.client_id == "netbox-to-diode") | .client_secret' ./diode/oauth2/client/client-credentials.json)` + ### Start NetBox with the Diode plugin installed and configured. > [!TIP] @@ -78,28 +92,27 @@ source 1_set_envvars.sh > NetBox runs a lot of database migrations when starting up for the first time so this can take a few minutes ``` -./2_start_netbox.sh +./3_start_netbox.sh ``` When this step finishes you can check that NetBox is working by logging into NetBox using the URL and credentials provided in the command line output. -### Start Diode. - -``` -./3_start_diode.sh -``` +### Generate Diode Client Credentials -### Configure NetBox to communicate with Diode +> [!TIP] +> NetBox credentials: +> username: `admin` +> password: `admin` -Go back to NetBox. On the left-hand menu bar navigate to `Diode` -> `Settings`. You'll see that the fields are already configured for you. +In order for the discovery agents to communicate with Diode, you need to create some client credentials. -Diode Settings - -You just need to click on `Create`. - -Then in the left-hand menu bar in NetBod click on `Diode` -> `Ingestion Logs` and you should see this: - -Diode Ingestion Logs +- Go to your NetBox instance +- In the left-hand pane navigate to `Diode` -> `Client Credentials` +- Click on `+ Add a Credential` +- For the `Client Name` enter any name you like and then click `Create` +- **IMPORTANT** on your command line, export the credentials so that they can be used in the next steps: + - `export DIODE_CLIENT_ID=""` + - `export DIODE_CLIENT_SECRET=""` Diode is now ready to start ingesting data from NetBox Discovery into our NetBox instance! @@ -121,6 +134,10 @@ We need some lab devices to run our device discovery against and for this we wil ./4_start_network.sh network/srl.clab.yml ``` +> [!TIP] +> +> If you see an `ERROR` followed by `Warning: No existing labs were destroyed or an error occurred.` you can ignore it. This step attempts to clean up any existing ContainerLab labs and the first time round there aren't any to clean up. + After a short while you should see a summary of your ContainerLab devices, like this: ``` @@ -141,7 +158,7 @@ NetBox Discovery has two modes: **Network Discovery** and **Device Discovery** > [!TIP] > -> You can find the full NetBox Discovery documentation here: [https://docs.netboxlabs.com/netbox-discovery/](https://docs.netboxlabs.com/netbox-discovery/) +> You can find the full NetBox Discovery documentation here: [https://netboxlabs.com/docs/diode/?focus=community](https://netboxlabs.com/docs/diode/?focus=community) **Network Discovery** uses `nmap` under the hood to find active IPs and ingests them into NetBox. @@ -162,13 +179,15 @@ orb: common: diode: target: grpc://${MY_EXTERNAL_IP}:8080/diode - api_key: ${DIODE_API_KEY} + client_id: ${DIODE_CLIENT_ID} + client_secret: ${DIODE_CLIENT_SECRET} agent_name: agent1 policies: network_discovery: - policy_1: + loopback_policy: + config: scope: - targets: + targets: - ${DOCKER_SUBNET} ``` @@ -177,9 +196,10 @@ Here you can see various variables that will be populated automatically when you ``` policies: network_discovery: - policy_1: + loopback_policy: + config: scope: - targets: + targets: - ${DOCKER_SUBNET} ``` @@ -195,9 +215,7 @@ Now let's run the network discovery! In our lab we have two SR Linux devices with management IPs at `172.24.0.100` and `172.24.0.101`. When we run our network discovery we should expect to find those, but also a few other IPs that are being used in our quickstart guide. You can ignore those. -Now go and take a look into NetBox under `Diode`-> `Ingestion Logs` and you should see records like this: - -Diode Ingestion Logs +Now go and take a look into NetBox under `IPAM`-> `IP Addresses` and you should see the IP addresses the network discovery found. Now exit out of network discovery with `Ctrl+C` @@ -216,8 +234,9 @@ orb: common: diode: target: grpc://${MY_EXTERNAL_IP}:8080/diode - api_key: ${DIODE_API_KEY} - agent_name: agent1 + client_id: ${DIODE_CLIENT_ID} + client_secret: ${DIODE_CLIENT_SECRET} + agent_name: agent2 policies: device_discovery: discovery_1: @@ -228,14 +247,14 @@ orb: scope: - driver: srl hostname: 172.24.0.100 - username: ${SRLINUX_USERNAME} - password: ${SRLINUX_PASSWORD} + username: admin + password: NokiaSrl1! optional_args: insecure: True - driver: srl hostname: 172.24.0.101 - username: ${SRLINUX_USERNAME} - password: ${SRLINUX_PASSWORD} + username: admin + password: NokiaSrl1! optional_args: insecure: True ``` @@ -246,14 +265,14 @@ Again you can see various variables that will be populated automatically when yo scope: - driver: srl hostname: 172.24.0.100 - username: ${SRLINUX_USERNAME} - password: ${SRLINUX_PASSWORD} + username: admin + password: NokiaSrl1! optional_args: insecure: True - driver: srl hostname: 172.24.0.101 - username: ${SRLINUX_USERNAME} - password: ${SRLINUX_PASSWORD} + username: admin + password: NokiaSrl1! optional_args: insecure: True ``` @@ -263,39 +282,18 @@ You can see that we need to provide the IPs, and SSH credentials for our lab dev Let's go ahead and run it: ``` -SRLINUX_USERNAME="admin" -SRLINUX_PASSWORD="NokiaSrl1!" ./6_start_device_discovery.sh ``` First NetBox Discovery will load the environment and the policies we've defined in our configuration. The configuration section `schedule: "* * * * *"` tells the discovery agent to run every minute, so you'll need to wait for a minute to pass for the first device discovery run to execute. -Keep an eye on the Diode ingestion logs by going to the left-hand menu in NetBox clicking on `Diode` -> `Ingestion logs`. Eventually you'll see our discovery ingestion logs show up with types including `Device`, `Prefix`, `IP Address`, and `Interface`. - -Diode Device Ingestion Logs - -> [!WARNING] -> You may notice some failures in the ingestion logs that look like this due to a known issue in Diode. We're working on a fix. -> `IP Address Failed agent1/device-discovery/0.3.0 diode-sdk-python/0.4.2 ab6b46cd-441f-4e26-aab4-7ceaab0d34db` - -You'll also notice in our configuration above that we defined the default site for devices to be `New York NY`. Go to NetBox and click on `Organization` -> `Sites` where you'll now see our `New York NY` site. - -Now click on `New York NY` and then `Devices` in the right hand pane, where you will now see our devices. - -NetBox Ingested Devices - -Now click on the first device `srl1`. Here you can see that the `Device Type`, `Platform` and `Status` have all been set correctly. - -NetBox Device Ingested srl1 - -Now click on the `Interfaces` tab for `srl1`. Now you'll see that all our our device interfaces have been successfully ingested into NetBox, with the correct administrative statuses which are called `Enabled` in NetBox. - -NetBox Device Ingested Interfaces - -Lastly, click on the top interface `ethernet-1/1`. Now you'll see that NetBox Discovery has correctly ingested the correct `MAC Address`, `MTU`, and `Speed/Duplex` for the interface, and also whether or not this is a management interface. - -NetBox Ingested Interface +- Keep an eye on `Devices` -> `Devices`. Eventually you'll see the discovered device details start to show up. +- You'll also notice in our configuration above that we defined the default site for devices to be `New York NY`. Go to NetBox and click on `Organization` -> `Sites` where you'll now see our `New York NY` site. +- Now click on `New York NY` and then `Devices` in the right hand pane, where you will now see our devices. +- Now click on the first device `srl1`. Here you can see that the `Device Type`, `Platform` and `Status` have all been set correctly. +- Now click on the `Interfaces` tab for `srl1`. Now you'll see that all our our device interfaces have been successfully ingested into NetBox, with the correct administrative statuses which are called `Enabled` in NetBox. +- Lastly, click on the top interface `ethernet-1/1`. Now you'll see that NetBox Discovery has correctly ingested the correct `MAC Address`, `MTU`, and `Speed/Duplex` for the interface. ## Conclusion -In this short guide you have learned the basics of NetBox Discovery's two modes of operation: network discovery and device discovery. Feel free to play around with the environment you've created, and to fork the repo to do your own experiments with NetBox Discovery. +In this short guide you have learned the basics of NetBox Discovery's two modes of operation: network discovery and device discovery. Feel free to play around with the environment you've created, and to fork the repo to do your own experiments with NetBox Discovery. \ No newline at end of file