Add custom AWX Execution Environment with NetBox support and related scripts

This commit is contained in:
alex-local
2025-09-12 09:44:55 +02:00
parent 585fa54336
commit e423305242
10 changed files with 500 additions and 84 deletions

11
ee/Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
# Custom AWX Execution Environment with NetBox support
# Extends the official AWX EE and installs pynetbox and the netbox collection
FROM quay.io/ansible/awx-ee:latest
USER root
# Install python dependency and the NetBox Ansible collection
RUN pip install --no-cache-dir pynetbox \
&& ansible-galaxy collection install netbox.netbox || true
# Drop back to non-root user used by the base image
USER 1000

31
ee/README.md Normal file
View File

@@ -0,0 +1,31 @@
Custom AWX Execution Environment: NetBox support
This folder contains a minimal Dockerfile and helper to create an AWX Execution
Environment that includes the NetBox Ansible collection and pynetbox.
Files:
- Dockerfile - derived from quay.io/ansible/awx-ee:latest, installs pynetbox and netbox.netbox
- build-and-load-ee.sh - builds the image and loads it into Minikube
Usage:
1. Build and load into minikube:
IMAGE_NAME=local/awx-ee-netbox:latest ./awx-local-setup/ee/build-and-load-ee.sh
2. Register this Execution Environment in AWX (UI or awx-cli / API). Use the image
name you built (local/awx-ee-netbox:latest) as the Execution Environment image.
3. Commit an inventory plugin file (example: inventory/netbox_inventory.yml) to
your project repository that uses the netbox.netbox.inventory plugin and
references the NetBox token and URL.
4. Create an AWX inventory source of type `scm` pointing to the project and set
`source_path` to the plugin file created in step 3. Ensure the inventory
source uses the custom Execution Environment.
Notes:
- If your Minikube cluster uses a remote container runtime you may need to push
the built image to a registry reachable by the cluster and set IMAGE_NAME
accordingly.
- For production, build and push to a private registry and configure AWX to
pull the image using pull secrets.

21
ee/build-and-load-ee.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
# build-and-load-ee.sh
# Build the custom AWX Execution Environment and load it into Minikube
IMAGE_NAME=${IMAGE_NAME:-local/awx-ee-netbox:latest}
MINIKUBE_PROFILE=${MINIKUBE_PROFILE:-minikube}
echo "Building EE image: $IMAGE_NAME"
docker build -t "$IMAGE_NAME" -f "$(dirname "$0")/ee/Dockerfile" .
# If minikube is running with docker driver we can use 'docker' directly, else load into minikube
if minikube status -p "$MINIKUBE_PROFILE" >/dev/null 2>&1; then
DRIVER=$(minikube status -p "$MINIKUBE_PROFILE" --format='{{.Host}}' || true)
fi
if minikube image load "$IMAGE_NAME" -p "$MINIKUBE_PROFILE"; then
echo "Loaded $IMAGE_NAME into minikube"
else
echo "Failed to use minikube image load; try docker push to a registry and update AWX EE settings"
fi