mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07: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.
|
- Database port to connect to.
|
||||||
required: no
|
required: no
|
||||||
default: 5432
|
default: 5432
|
||||||
|
unix_socket:
|
||||||
|
description
|
||||||
|
- Path to a Unix domain socket for local connections.
|
||||||
|
- 'Alias: I(login_unix_socket)'
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
login:
|
login:
|
||||||
description:
|
description:
|
||||||
- The username to authenticate with.
|
- 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
|
kw = dict( (params_map[k], getattr(params, k)) for k in params_map
|
||||||
if getattr(params, k) != '' )
|
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.connection = psycopg2.connect(**kw)
|
||||||
self.cursor = self.connection.cursor()
|
self.cursor = self.connection.cursor()
|
||||||
|
|
||||||
|
@ -520,6 +532,7 @@ def main():
|
||||||
aliases=['admin_option']),
|
aliases=['admin_option']),
|
||||||
host=dict(default='', aliases=['login_host']),
|
host=dict(default='', aliases=['login_host']),
|
||||||
port=dict(type='int', default=5432),
|
port=dict(type='int', default=5432),
|
||||||
|
unix_socket=dict(default='', aliases=['login_unix_socket']),
|
||||||
login=dict(default='postgres', aliases=['login_user']),
|
login=dict(default='postgres', aliases=['login_user']),
|
||||||
password=dict(default='', aliases=['login_password'])
|
password=dict(default='', aliases=['login_password'])
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue