feat: deployable playbook
This commit is contained in:
parent
f8e1de4f0a
commit
7ab2b719dc
23 changed files with 754 additions and 176 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue