feat: deployable playbook

This commit is contained in:
Doni Crosby 2025-09-27 13:36:00 -04:00
parent f8e1de4f0a
commit 7ab2b719dc
23 changed files with 754 additions and 176 deletions

View file

@ -25,6 +25,11 @@ netbox_redis_host: "redis"
netbox_redis_port: "6379"
netbox_redis_password: ""
# Redis Cache configuration
netbox_redis_cache_host: "redis-cache"
netbox_redis_cache_port: "6379"
netbox_redis_cache_password: ""
# NetBox settings
netbox_allowed_hosts: "localhost,127.0.0.1"
netbox_time_zone: "UTC"

View file

@ -45,7 +45,7 @@
- name: Generate NetBox secret key
set_fact:
netbox_secret_key: "{{ netbox_secret_key | default(128 | random_string) }}"
netbox_secret_key: "{{ netbox_secret_key | default(ansible.builtin.random_string(length=128)) }}"
when: netbox_secret_key == ""
tags:
- netbox-deploy
@ -97,15 +97,15 @@
- config
- name: Pull Docker images
docker_compose:
community.docker.docker_compose_v2:
project_src: "{{ netbox_install_dir }}"
pull: yes
pull: always
tags:
- netbox-deploy
- docker-pull
- name: Start NetBox services
docker_compose:
community.docker.docker_compose_v2:
project_src: "{{ netbox_install_dir }}"
state: present
tags:
@ -114,31 +114,14 @@
- name: Wait for NetBox to be ready
uri:
url: "http://localhost:8000/"
url: "https://{{ netbox_domain }}/"
method: GET
status_code: 200
validate_certs: false
register: netbox_ready
until: netbox_ready.status == 200
retries: 30
delay: 10
tags:
- netbox-deploy
- health-check
- name: Create NetBox superuser
docker_compose:
project_src: "{{ netbox_install_dir }}"
command: "netbox /opt/netbox/netbox/manage.py createsuperuser --noinput --username {{ netbox_superuser_name }} --email {{ netbox_superuser_email }}"
register: superuser_result
failed_when: superuser_result.rc != 0 and "already exists" not in superuser_result.stderr
tags:
- netbox-deploy
- superuser
- name: Set NetBox superuser password
docker_compose:
project_src: "{{ netbox_install_dir }}"
command: "netbox /opt/netbox/netbox/manage.py shell -c \"from django.contrib.auth import get_user_model; User = get_user_model(); u = User.objects.get(username='{{ netbox_superuser_name }}'); u.set_password('{{ netbox_superuser_password }}'); u.save()\""
tags:
- netbox-deploy
- superuser
- health-check

View file

@ -1,8 +0,0 @@
---
# Variables for netbox-deploy role
netbox_install_dir: "/opt/netbox-docker"
netbox_repo_url: "https://github.com/netbox-community/netbox-docker.git"
netbox_repo_branch: "release"
netbox_repo_update: true
netbox_backup_dir: "/opt/netbox-backups"
netbox_data_dir: "/opt/netbox-data"