From 7b2df1e99b5e1b6c65d85b9332fca316eb778dc6 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Sun, 29 Jan 2023 14:46:03 +0100 Subject: [PATCH] Add `netbox_database_maintenance` variable --- README.adoc | 8 ++++++++ defaults/main.yml | 1 + tasks/main.yml | 2 ++ 3 files changed, 11 insertions(+) diff --git a/README.adoc b/README.adoc index 6371c1d..8e4568e 100644 --- a/README.adoc +++ b/README.adoc @@ -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 @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml index e1f5f62..fbc8286 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: [] diff --git a/tasks/main.yml b/tasks/main.yml index ae917cd..b6a574d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: @@ -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