Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
7752a560
Commit
7752a560
authored
Sep 06, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'devel' of
https://github.com/abompard/ansible
into abompard-devel
parents
71bf9495
5a949dca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
library/database/postgresql_privs
+18
-9
No files found.
library/database/postgresql_privs
View file @
7752a560
...
...
@@ -249,12 +249,21 @@ def partial(f, *args, **kwargs):
class
Connection
(
object
)
:
"""Wrapper around a psycopg2 connection with some convenience methods"""
def
__init__
(
self
,
host
,
port
,
login
,
password
,
database
)
:
self
.
database
=
database
self
.
connection
=
psycopg2
.
connect
(
host
=
host
,
port
=
port
,
user
=
login
,
password
=
password
,
database
=
database
)
def
__init__
(
self
,
params
)
:
self
.
database
=
params
.
database
# To use defaults values, keyword arguments must be absent, so
# check which values are empty and don't include in the **kw
# dictionary
params_map
=
{
"host"
:
"host"
,
"login"
:
"user"
,
"password"
:
"password"
,
"port"
:
"port"
,
"database"
:
"database"
,
}
kw
=
dict
(
(
params_map
[
k
],
getattr
(
params
,
k
))
for
k
in
params_map
if
getattr
(
params
,
k
)
!=
''
)
self
.
connection
=
psycopg2
.
connect
(
**
kw
)
self
.
cursor
=
self
.
connection
.
cursor
()
...
...
@@ -503,10 +512,10 @@ def main():
roles
=
dict
(
required
=
True
,
aliases
=
[
'
role
'
]),
grant_option
=
dict
(
required
=
False
,
type
=
'
bool
'
,
aliases
=
[
'
admin_option
'
]),
host
=
dict
(
required
=
False
,
aliases
=
[
'
login_host
'
]),
host
=
dict
(
default
=
''
,
aliases
=
[
'
login_host
'
]),
port
=
dict
(
type
=
'
int
'
,
default
=
5432
),
login
=
dict
(
default
=
'
postgres
'
,
aliases
=
[
'
login_user
'
]),
password
=
dict
(
required
=
False
,
aliases
=
[
'
login_password
'
])
password
=
dict
(
default
=
''
,
aliases
=
[
'
login_password
'
])
),
supports_check_mode
=
True
)
...
...
@@ -541,7 +550,7 @@ def main():
if
not
psycopg2
:
module
.
fail_json
(
msg
=
'
Python
module
"psycopg2"
must
be
installed
.
'
)
try
:
conn
=
Connection
(
p
.
host
,
p
.
port
,
p
.
login
,
p
.
password
,
p
.
database
)
conn
=
Connection
(
p
)
except
psycopg2
.
Error
,
e
:
module
.
fail_json
(
msg
=
'
Could
not
connect
to
database
:
%
s
'
%
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment