Skip to content

Commit 7c73157

Browse files
authored
Merge pull request #199 from tyler-8/alternative_socket_use
Alternative socket use
2 parents 76610c2 + eb92b92 commit 7c73157

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

README.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,17 @@ netbox_database_user: netbox
155155
#netbox_database_host: localhost
156156
netbox_database_port: 5432
157157
#netbox_database_socket: /var/run/postgresql
158+
#netbox_database_alt_socket: false
158159
----
159160

160161
It is *required* to configure either a socket directory (to communicate over UNIX sockets) or a host/password (to use TCP/IP).
161162
See the _Example Playbook_ section for more information on configuring the database.
162163

164+
Setting `netbox_database_alt_socket` to `true` will skip the database connectivity check
165+
tasks and also set `netbox_database_port` alongside the socket connection for the
166+
database configuration. This will help with environments that may be running pgbouncer
167+
on the same server as NetBox.
168+
163169
Note that these are used to configure `DATABASE` in `configuration.py`.
164170

165171
[source,yaml]

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ netbox_database_user: netbox
2222
# netbox_database_host: localhost
2323
netbox_database_port: 5432
2424
# netbox_database_socket: /var/run/postgresql
25+
netbox_database_alt_socket: false
2526
netbox_database_conn_age: 0
2627
netbox_database_options: {}
2728
netbox_database_maintenance: "postgres"

tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
when:
5353
- netbox_database_socket is defined
5454
- netbox_database_host is not defined
55+
- not netbox_database_alt_socket
5556

5657
- name: Ensure Postgres database exists (via TCP)
5758
community.postgresql.postgresql_db:

templates/configuration.py.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ DATABASE = {
2525
{% if netbox_database_password is defined %}
2626
'PASSWORD': '{{ netbox_database_password }}',
2727
{% endif %}
28+
{% if netbox_database_alt_socket and netbox_database_socket is defined %}
29+
'PORT': '{{ netbox_database_port }}',
30+
{% endif %}
2831
'HOST': '{{ netbox_database_socket }}',
2932
{% endif %}
3033
'CONN_MAX_AGE': {{ netbox_database_conn_age }},

0 commit comments

Comments
 (0)