mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds a login_unix_socket option to the postgresql_privs module.
This commit is contained in:
parent
ee65c55fb0
commit
fe787f1bc9
1 changed files with 26 additions and 13 deletions
|
@ -99,6 +99,12 @@ options:
|
|||
- Database port to connect to.
|
||||
required: no
|
||||
default: 5432
|
||||
unix_socket:
|
||||
description
|
||||
- Path to a Unix domain socket for local connections.
|
||||
- 'Alias: I(login_unix_socket)'
|
||||
required: false
|
||||
default: null
|
||||
login:
|
||||
description:
|
||||
- The username to authenticate with.
|
||||
|
@ -267,6 +273,12 @@ class Connection(object):
|
|||
}
|
||||
kw = dict( (params_map[k], getattr(params, k)) for k in params_map
|
||||
if getattr(params, k) != '' )
|
||||
|
||||
# If a unix_socket is specified, incorporate it here.
|
||||
is_localhost = "host" not in kw or kw["host"] == "" or kw["host"] == "localhost"
|
||||
if is_localhost and params.unix_socket != "":
|
||||
kw["host"] = params.unix_socket
|
||||
|
||||
self.connection = psycopg2.connect(**kw)
|
||||
self.cursor = self.connection.cursor()
|
||||
|
||||
|
@ -520,6 +532,7 @@ def main():
|
|||
aliases=['admin_option']),
|
||||
host=dict(default='', aliases=['login_host']),
|
||||
port=dict(type='int', default=5432),
|
||||
unix_socket=dict(default='', aliases=['login_unix_socket']),
|
||||
login=dict(default='postgres', aliases=['login_user']),
|
||||
password=dict(default='', aliases=['login_password'])
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue