Skip to content

Commit

Permalink
chore: Sync development with the cookiecutter template
Browse files Browse the repository at this point in the history
  • Loading branch information
snaselj committed Jun 9, 2023
1 parent cd45782 commit c03835e
Show file tree
Hide file tree
Showing 23 changed files with 564 additions and 409 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,5 @@ invoke.yml

# Static docs
/nautobot_chatops/static/nautobot_chatops/docs/
compose.yaml
/compose.yaml
/dump.sql
1 change: 1 addition & 0 deletions changes/194.added
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Added Mattermost container for the development.
Improved invoke tasks.
2 changes: 1 addition & 1 deletion development/ansible/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ x-nautobot: &nautobot
services:
nautobot:
<<: *nautobot
celery:
worker:
<<: *nautobot
networks:
awx: {}
35 changes: 27 additions & 8 deletions development/creds.example.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
# nautobot_chatops
################################################################################
# CREDS File: Store private information. Copied to creds.env and always ignored
################################################################################
# Nautobot Configuration Secret Items
NAUTOBOT_CREATE_SUPERUSER=true
NAUTOBOT_DB_PASSWORD=changeme
NAUTOBOT_NAPALM_USERNAME=''
NAUTOBOT_NAPALM_PASSWORD=''
NAUTOBOT_REDIS_PASSWORD=changeme
NAUTOBOT_SECRET_KEY='changeme'
NAUTOBOT_SUPERUSER_NAME=admin
NAUTOBOT_SUPERUSER_EMAIL=admin@example.com
NAUTOBOT_SUPERUSER_PASSWORD=admin
NAUTOBOT_SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567

# Postgres
POSTGRES_PASSWORD=${NAUTOBOT_DB_PASSWORD}
PGPASSWORD=${NAUTOBOT_DB_PASSWORD}

# MySQL Credentials
MYSQL_ROOT_PASSWORD=${NAUTOBOT_DB_PASSWORD}
MYSQL_PASSWORD=${NAUTOBOT_DB_PASSWORD}

# Use these to override values in development.env
# NAUTOBOT_DB_HOST=localhost
# NAUTOBOT_REDIS_HOST=localhost
# NAUTOBOT_CONFIG=development/nautobot_config.py
SLACK_API_TOKEN=xoxb-...
SLACK_SIGNING_SECRET=...
# SLACK_SLASH_COMMAND_PREFIX=/
Expand All @@ -7,13 +33,6 @@ MICROSOFT_APP_PASSWORD=...
WEBEX_TEAMS_ACCESS_TOKEN=...
WEBEX_TEAMS_SIGNING_SECRET=...
MATTERMOST_API_TOKEN="5qsffxoapt883qfdygbdgf17jy"
POSTGRES_PASSWORD=notverysecurepwd
REDIS_PASSWORD=notverysecurepwd
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
NAUTOBOT_CREATE_SUPERUSER=true
NAUTOBOT_SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
NAUTOBOT_SUPERUSER_PASSWORD=admin
NAUTOBOT_TOWER_PASSWORD="password"

# Cisco ACI Chatops Plugin Settings
# First APIC
Expand Down
38 changes: 0 additions & 38 deletions development/dev.env

This file was deleted.

46 changes: 46 additions & 0 deletions development/development.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
################################################################################
# DEV File: Store environment information. NOTE: Secrets NOT stored here!
################################################################################
# Nautobot Configuration Environment Variables
NAUTOBOT_ALLOWED_HOSTS=*
NAUTOBOT_BANNER_TOP="Local"
NAUTOBOT_CHANGELOG_RETENTION=0

NAUTOBOT_DEBUG=True
NAUTOBOT_DJANGO_EXTENSIONS_ENABLED=True
NAUTOBOT_DJANGO_TOOLBAR_ENABLED=True
NAUTOBOT_LOG_LEVEL=DEBUG
NAUTOBOT_METRICS_ENABLED=True
NAUTOBOT_NAPALM_TIMEOUT=5
NAUTOBOT_MAX_PAGE_SIZE=0

# Redis Configuration Environment Variables
NAUTOBOT_REDIS_HOST=redis
NAUTOBOT_REDIS_PORT=6379
# Uncomment NAUTOBOT_REDIS_SSL if using SSL
# NAUTOBOT_REDIS_SSL=True

# Nautobot DB Connection Environment Variables
NAUTOBOT_DB_NAME=nautobot
NAUTOBOT_DB_USER=nautobot
NAUTOBOT_DB_HOST=db
NAUTOBOT_DB_TIMEOUT=300

# Use them to overwrite the defaults in nautobot_config.py
# NAUTOBOT_DB_ENGINE=django.db.backends.postgresql
# NAUTOBOT_DB_PORT=5432

# Needed for Postgres should match the values for Nautobot above
POSTGRES_USER=${NAUTOBOT_DB_USER}
POSTGRES_DB=${NAUTOBOT_DB_NAME}

# Needed for MYSQL should match the values for Nautobot above
MYSQL_USER=${NAUTOBOT_DB_USER}
MYSQL_DATABASE=${NAUTOBOT_DB_NAME}
MYSQL_ROOT_HOST=%

MATTERMOST_URL="http://mattermost:8065"

NAUTOBOT_TOWER_URI="https://awx:8043/"
NAUTOBOT_TOWER_USERNAME="awx"
NAUTOBOT_TOWER_VERIFY_SSL="False"
3 changes: 3 additions & 0 deletions development/development_mysql.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Custom ENVs for Mysql
# Due to docker image limitations for Mysql, we need "root" user to create more than one database table
NAUTOBOT_DB_USER=root
35 changes: 27 additions & 8 deletions development/docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,40 @@ x-nautobot-build: &nautobot-build
x-nautobot-base: &nautobot-base
image: "nautobot-chatops-plugin/nautobot:${NAUTOBOT_VER}-py${PYTHON_VER}"
env_file:
- "dev.env"
- "development.env"
- "creds.env"
tty: true

version: "3.4"
version: "3.8"
services:
nautobot:
ports:
- "8080:8080"
depends_on:
- "postgres"
- "redis"
<<: [*nautobot-build, *nautobot-base]
redis:
condition: "service_started"
db:
condition: "service_healthy"
<<:
- *nautobot-base
- *nautobot-build
worker:
entrypoint: "nautobot-server rqworker"
entrypoint:
- "sh"
- "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env
- "watchmedo auto-restart --directory './' --pattern '*.py' --recursive -- nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events" ## $$ because of docker-compose
depends_on:
- "nautobot"
healthcheck:
interval: "30s"
timeout: "10s"
start_period: "30s"
retries: 3
test: ["CMD", "bash", "-c", "nautobot-server celery inspect ping --destination celery@$$HOSTNAME"] ## $$ because of docker-compose
<<: *nautobot-base
beat:
entrypoint:
- "sh"
- "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env
- "nautobot-server celery beat -l $$NAUTOBOT_LOG_LEVEL" ## $$ because of docker-compose
depends_on:
- "nautobot"
healthcheck:
Expand Down
17 changes: 0 additions & 17 deletions development/docker-compose.celery.yml

This file was deleted.

14 changes: 12 additions & 2 deletions development/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# any override will need to include these volumes to use them.
# see: https://github.com/docker/compose/issues/3729
---
version: "3.4"
version: "3.8"
services:
nautobot:
command: "nautobot-server runserver 0.0.0.0:8080"
ports:
- "8080:8080"
volumes:
- "./nautobot_config.py:/opt/nautobot/nautobot_config.py"
- "../:/source"
Expand All @@ -15,7 +17,8 @@ services:
ports:
- "8001:8080"
volumes:
- "../:/source"
- "../docs:/source/docs:ro"
- "../mkdocs.yml:/source/mkdocs.yml:ro"
image: "nautobot-chatops-plugin/nautobot:${NAUTOBOT_VER}-py${PYTHON_VER}"
healthcheck:
disable: true
Expand All @@ -24,3 +27,10 @@ services:
volumes:
- "./nautobot_config.py:/opt/nautobot/nautobot_config.py"
- "../:/source"
# To expose postgres or redis to the host uncomment the following
# postgres:
# ports:
# - "5432:5432"
# redis:
# ports:
# - "6379:6379"
40 changes: 40 additions & 0 deletions development/docker-compose.mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
version: "3.8"

services:
nautobot:
environment:
- "NAUTOBOT_DB_ENGINE=django.db.backends.mysql"
env_file:
- "development.env"
- "creds.env"
- "development_mysql.env"
worker:
environment:
- "NAUTOBOT_DB_ENGINE=django.db.backends.mysql"
env_file:
- "development.env"
- "creds.env"
- "development_mysql.env"
db:
image: "mysql:8"
command:
- "--default-authentication-plugin=mysql_native_password"
- "--max_connections=200"
env_file:
- "development.env"
- "creds.env"
- "development_mysql.env"
volumes:
- "mysql_data:/var/lib/mysql"
healthcheck:
test:
- "CMD"
- "mysqladmin"
- "ping"
- "-h"
- "localhost"
timeout: "20s"
retries: 10
volumes:
mysql_data: {}
26 changes: 26 additions & 0 deletions development/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
version: "3.8"

services:
nautobot:
environment:
- "NAUTOBOT_DB_ENGINE=django.db.backends.postgresql"
db:
image: "postgres:13-alpine"
command:
- "-c"
- "max_connections=200"
env_file:
- "development.env"
- "creds.env"
volumes:
# - "./nautobot.sql:/tmp/nautobot.sql"
- "postgres_data:/var/lib/postgresql/data"
healthcheck:
test: "pg_isready --username=$$POSTGRES_USER --dbname=$$POSTGRES_DB"
interval: "10s"
timeout: "5s"
retries: 10

volumes:
postgres_data: {}
12 changes: 12 additions & 0 deletions development/docker-compose.redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: "3.8"
services:
redis:
image: "redis:6-alpine"
command:
- "sh"
- "-c" # this is to evaluate the $NAUTOBOT_REDIS_PASSWORD from the env
- "redis-server --appendonly yes --requirepass $$NAUTOBOT_REDIS_PASSWORD"
env_file:
- "development.env"
- "creds.env"
25 changes: 0 additions & 25 deletions development/docker-compose.requirements.yml

This file was deleted.

17 changes: 0 additions & 17 deletions development/docker-compose.socket.yml

This file was deleted.

2 changes: 1 addition & 1 deletion development/mattermost/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: "3.8"
services:
nautobot:
<<: *nautobot
celery:
worker:
<<: *nautobot
mattermost:
image: "mattermost/mattermost-preview"
Expand Down
Loading

0 comments on commit c03835e

Please sign in to comment.