Skip to content

Commit 242596d

Browse files
feat(nautobot): Adds nautobot container build
1 parent b4c7902 commit 242596d

File tree

13 files changed

+453
-1
lines changed

13 files changed

+453
-1
lines changed

.github/workflows/containers.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- dnsmasq
3434
- ironic-nautobot-client
3535
- understack-tests
36+
- nautobot
3637
uses: ./.github/workflows/build-container-reuse.yaml
3738
secrets: inherit
3839
with:

ansible/roles/openstack_octavia/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
- name: Build octavia_port_names (override or hostname)
9393
ansible.builtin.set_fact:
94-
octavia_port_names: "{{ octavia_port_names | default([]) + [ (hostvars[item].octavia_host_override | default(item)) ] }}"
94+
octavia_port_names: "{{ octavia_port_names | default([]) + [hostvars[item].octavia_host_override | default(item)] }}"
9595
loop: "{{ groups['all'] }}"
9696
when:
9797
- hostvars[item].ovs_enabled is defined

containers/nautobot/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# renovate: datasource=docker depName=networktocode/nautobot versioning=semver
2+
ARG NAUTOBOT_VERSION=3.0.2
3+
ARG PYTHON_VERSION=3.12
4+
ARG NAUTOBOT_CONTAINER_TYPE=""
5+
6+
FROM ghcr.io/nautobot/nautobot${NAUTOBOT_CONTAINER_TYPE}:${NAUTOBOT_VERSION}-py${PYTHON_VERSION} AS prod
7+
8+
LABEL org.opencontainers.image.source=https://github.com/rackerlabs/understack
9+
10+
ENV PIP_NO_CACHE_DIR=off \
11+
PIP_DISABLE_PIP_VERSION_CHECK=on \
12+
PIP_DEFAULT_TIMEOUT=100
13+
14+
# install plugin_requirements to /opt/nautobot/ per the Nautobot Docker Compose example
15+
COPY ./containers/nautobot/plugin_requirements.txt /opt/nautobot/
16+
RUN pip install --no-warn-script-location -r /opt/nautobot/plugin_requirements.txt
17+
# copy in a sample config
18+
COPY ./containers/nautobot/nautobot_config.py /opt/nautobot_config/nautobot_config.py
19+
# copy in the healthcheck script for celery beats
20+
COPY ./containers/nautobot/scripts/nautobot_celery_beats_hcheck.py /opt/nautobot/

containers/nautobot/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# nautobot container builds
2+
3+
``` bash
4+
docker compose -f docker-compose.nautobot.yml -f docker-compose.postgres.yml -f docker-compose.redis.yml build
5+
docker compose -f docker-compose.nautobot.yml -f docker-compose.postgres.yml -f docker-compose.redis.yml up
6+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# default creds file
2+
3+
NAUTOBOT_DB_PASSWORD=changeme
4+
NAUTOBOT_REDIS_PASSWORD=changeme
5+
NAUTOBOT_SECRET_KEY=changeme
6+
7+
NAUTOBOT_SUPERUSER_NAME=admin
8+
NAUTOBOT_SUPERUSER_EMAIL=[email protected]
9+
NAUTOBOT_SUPERUSER_PASSWORD=admin
10+
NAUTOBOT_SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
################################################################################
2+
# DEV File: Store environment information. NOTE: Secrets NOT stored here!
3+
################################################################################
4+
# Nautobot Configuration Environment Variables
5+
NAUTOBOT_ALLOWED_HOSTS=*
6+
NAUTOBOT_BANNER_TOP="Local"
7+
NAUTOBOT_CHANGELOG_RETENTION=0
8+
NAUTOBOT_CONFIG=/opt/nautobot_config/nautobot_config.py
9+
10+
NAUTOBOT_CREATE_SUPERUSER=true
11+
NAUTOBOT_DEBUG=True
12+
NAUTOBOT_DJANGO_EXTENSIONS_ENABLED=True
13+
NAUTOBOT_DJANGO_TOOLBAR_ENABLED=True
14+
NAUTOBOT_LOG_LEVEL=DEBUG
15+
NAUTOBOT_METRICS_ENABLED=True
16+
NAUTOBOT_NAPALM_TIMEOUT=5
17+
NAUTOBOT_MAX_PAGE_SIZE=0
18+
19+
# Redis Configuration Environment Variables
20+
NAUTOBOT_REDIS_HOST=redis
21+
NAUTOBOT_REDIS_PORT=6379
22+
# Uncomment NAUTOBOT_REDIS_SSL if using SSL
23+
# NAUTOBOT_REDIS_SSL=True
24+
25+
# Nautobot DB Connection Environment Variables
26+
NAUTOBOT_DB_ENGINE=django.db.backends.postgresql
27+
NAUTOBOT_DB_NAME=nautobot
28+
NAUTOBOT_DB_USER=nautobot
29+
NAUTOBOT_DB_HOST=db
30+
NAUTOBOT_DB_TIMEOUT=300
31+
32+
# Use them to overwrite the defaults in nautobot_config.py
33+
# NAUTOBOT_DB_ENGINE=django.db.backends.postgresql
34+
# NAUTOBOT_DB_PORT=5432
35+
36+
# Needed for Postgres should match the values for Nautobot above
37+
POSTGRES_USER=${NAUTOBOT_DB_USER}
38+
POSTGRES_DB=${NAUTOBOT_DB_NAME}
39+
40+
# Needed to initialize the Postgres super user, use the same for dev
41+
POSTGRES_PASSWORD=${NAUTOBOT_DB_PASSWORD}
42+
43+
NAUTOBOT_SSOT_HIDE_EXAMPLE_JOBS="True"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
version: "3.8"
3+
name: undercloud-nautobot
4+
services:
5+
setup:
6+
profiles: ["setup"]
7+
image: local/undercloud-nautobot-ansible:latest
8+
build:
9+
context: ../ansible
10+
dockerfile: Dockerfile
11+
env_file:
12+
- "rax-creds.env"
13+
restart: 'no'
14+
volumes:
15+
- "../:/source"
16+
depends_on:
17+
nautobot:
18+
condition: "service_healthy"
19+
worker:
20+
condition: "service_healthy"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
version: "3.8"
3+
name: undercloud-nautobot
4+
services:
5+
nautobot:
6+
image: local/understack-nautobot:latest
7+
build:
8+
context: ../../.
9+
dockerfile: containers/nautobot/Dockerfile
10+
env_file:
11+
- "default-creds.env"
12+
- "development.env"
13+
environment:
14+
- PYTHONDONTWRITEBYTECODE=1
15+
ports:
16+
- "8000:8080"
17+
depends_on:
18+
redis:
19+
condition: "service_started"
20+
db:
21+
condition: "service_healthy"
22+
healthcheck:
23+
interval: "30s"
24+
timeout: "30s"
25+
start_period: "30s"
26+
retries: 15
27+
worker:
28+
image: local/undercloud-nautobot:latest
29+
build:
30+
context: ../../.
31+
dockerfile: containers/nautobot/Dockerfile
32+
entrypoint:
33+
- "sh"
34+
- "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env and $$ because of docker-compose
35+
- "nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events"
36+
env_file:
37+
- "default-creds.env"
38+
- "development.env"
39+
environment:
40+
- PYTHONDONTWRITEBYTECODE=1
41+
depends_on:
42+
nautobot:
43+
condition: "service_started"
44+
healthcheck:
45+
interval: "30s"
46+
timeout: "30s" # its taking a long time to start sometimes
47+
start_period: "30s"
48+
retries: 10
49+
test: ["CMD", "bash", "-c", "nautobot-server celery inspect ping --destination celery@$$HOSTNAME"] ## $$ because of docker-compose
50+
51+
nautobot-celery-beats:
52+
image: local/undercloud-nautobot:latest
53+
build:
54+
context: ../../.
55+
dockerfile: containers/nautobot/Dockerfile
56+
environment:
57+
- PYTHONDONTWRITEBYTECODE=1
58+
entrypoint:
59+
- "sh"
60+
- "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env and $$ because of docker-compose
61+
- "nautobot-server celery beat -l $$NAUTOBOT_LOG_LEVEL"
62+
env_file:
63+
- "default-creds.env"
64+
- "development.env"
65+
depends_on:
66+
nautobot:
67+
condition: "service_healthy"
68+
healthcheck:
69+
interval: "30s"
70+
timeout: "10s"
71+
start_period: "30s"
72+
retries: 3
73+
test: ["CMD", "python", "/opt/nautobot/nautobot_celery_beats_hcheck.py"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
version: "3.8"
3+
name: undercloud-nautobot
4+
services:
5+
nautobot:
6+
environment:
7+
- "NAUTOBOT_DB_ENGINE=django.db.backends.postgresql"
8+
db:
9+
image: "postgres:16-alpine"
10+
env_file:
11+
- "default-creds.env"
12+
- "development.env"
13+
volumes:
14+
- "postgres_data:/var/lib/postgresql/data"
15+
healthcheck:
16+
test: "pg_isready --username=$$POSTGRES_USER --dbname=$$POSTGRES_DB"
17+
interval: "10s"
18+
timeout: "5s"
19+
retries: 10
20+
21+
volumes:
22+
postgres_data: {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
version: "3.8"
3+
name: undercloud-nautobot
4+
services:
5+
redis:
6+
image: "redis:7-alpine"
7+
command:
8+
- "sh"
9+
- "-c" # this is to evaluate the $NAUTOBOT_REDIS_PASSWORD from the env
10+
- "redis-server --appendonly yes --requirepass $$NAUTOBOT_REDIS_PASSWORD"
11+
env_file:
12+
- "default-creds.env"
13+
- "development.env"

0 commit comments

Comments
 (0)