Skip to content

Commit

Permalink
Merge pull request #13 from k-304/support-netbox-on-psql-cluster
Browse files Browse the repository at this point in the history
Add support for standby NetBox on read only PSQL database
  • Loading branch information
k-304 authored and urscale committed May 29, 2024
1 parent 2bbe9dc commit 272ec34
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions ansible/roles/netbox/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,57 @@
not netbox__primary|bool)
changed_when: false

- name: Generate static content
## Since we do not run the manage.py file on secondary sites
## we need to generate those files in an extra task.
shell: # noqa no-handler
cmd: |
set -o nounset -o pipefail -o errexit
./manage.py collectstatic --no-input
chdir: '{{ netbox__git_checkout + "/netbox" }}'
executable: 'bash'
environment:
VIRTUAL_ENV: '{{ netbox__virtualenv }}'
PATH: '{{ netbox__virtualenv_env_path }}'
become: True
become_user: '{{ netbox__user }}'
when: (netbox__register_checkout is changed and
not netbox__primary|bool)
register: netbox__register_collectstatic
changed_when: not netbox__register_collectstatic.stdout is search('0 static files copied')

- name: Create local session directory
file:
path: '{{ netbox__data + "/sessions" }}'
owner: '{{ netbox__user }}'
group: '{{ netbox__group }}'
mode: '0770'
access_time: preserve
modification_time: preserve
state: directory
become: True
become_user: '{{ netbox__user }}'
when: (not netbox__primary|bool)

- name: Cleanup stale contenttypes and sessions
## Since we do not run the manage.py file on secondary sites
## we need to run the cleanup in an extra task.
shell: # noqa no-handler
cmd: |
set -o nounset -o pipefail -o errexit
./manage.py remove_stale_contenttypes --no-input
./manage.py clearsessions
chdir: '{{ netbox__git_checkout + "/netbox" }}'
executable: 'bash'
environment:
VIRTUAL_ENV: '{{ netbox__virtualenv }}'
PATH: '{{ netbox__virtualenv_env_path }}'
become: True
become_user: '{{ netbox__user }}'
when: (netbox__register_checkout is changed and
not netbox__primary|bool)
changed_when: false

- name: Create Django superuser account
community.general.django_manage:
command: 'createsuperuser --noinput --username={{ netbox__superuser_name }} --email={{ netbox__superuser_email }}'
Expand Down

0 comments on commit 272ec34

Please sign in to comment.