Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add netbox_database_maintenance variable #158

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}"
MonsterDruide1 marked this conversation as resolved.
Show resolved Hide resolved
when:
- netbox_database_socket is not defined
- netbox_database_host is defined
Expand Down