Skip to content

Commit

Permalink
Merge pull request #158 from MonsterDruide1/maintenance-db
Browse files Browse the repository at this point in the history
Add `netbox_database_maintenance` variable
  • Loading branch information
lae authored Feb 2, 2023
2 parents 8054a51 + 7b2df1e commit efca97d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ To configure Netbox to keep database connections open longer than a single reque
set `netbox_database_conn_age` to your preferred maximum connection age, in seconds.
300 seconds (5 minutes) is typically a good number to start with.

[source,yaml]
----
netbox_database_maintenance: postgres
----

If the postgres database is configured to only allow access to specific tables of the DB for the user configured with Netbox, you can set `netbox_database_maintenance` to replace the default database used for connection checking to a different table than the default `postgres`. This is an empty table in every postgres database by default, but some configurations might block access to this table, so a different table (i.e. `netbox_prod`) can be used here instead.

[source,yaml]
----
# Example usage, default is empty dict
Expand Down Expand Up @@ -501,6 +508,7 @@ installing NetBox on to authenticate with it over TCP:
netbox_database: netbox_prod
netbox_database_user: netbox_prod_user
netbox_database_password: "very_secure_password_for_prod"
netbox_database_maintenance: netbox_prod
redis_bind: 127.0.0.1
redis_version: 6.0.9
redis_checksum: sha256:dc2bdcf81c620e9f09cfd12e85d3bc631c897b2db7a55218fd8a65eaa37f86dd
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ netbox_database_port: 5432
# netbox_database_socket: /var/run/postgresql
netbox_database_conn_age: 0
netbox_database_options: {}
netbox_database_maintenance: "postgres"

netbox_redis_host: 127.0.0.1
netbox_redis_sentinels: []
Expand Down
2 changes: 2 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
name: "{{ netbox_database }}"
login_user: "{{ netbox_database_user }}"
login_unix_socket: "{{ netbox_database_socket }}"
maintenance_db: "{{ netbox_database_maintenance }}"
become: true
become_user: "{{ netbox_database_user }}"
when:
Expand All @@ -59,6 +60,7 @@
port: "{{ netbox_database_port }}"
login_user: "{{ netbox_database_user }}"
login_password: "{{ netbox_database_password }}"
maintenance_db: "{{ netbox_database_maintenance }}"
when:
- netbox_database_socket is not defined
- netbox_database_host is defined
Expand Down

0 comments on commit efca97d

Please sign in to comment.