Adds a login_unix_socket option to the postgresql_privs module.

pull/18777/head
Dan 10 years ago committed by Matt Clay
parent ee65c55fb0
commit fe787f1bc9

@ -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…
Cancel
Save