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
621eb5ec
Commit
621eb5ec
authored
Feb 20, 2013
by
Rodney Quillo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add postgresql_db and postgresql_use checkmode.
parent
6d604469
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
library/postgresql_db
+12
-1
library/postgresql_user
+20
-1
No files found.
library/postgresql_db
View file @
621eb5ec
...
...
@@ -59,6 +59,11 @@ options:
- Encoding of the database
required: false
default: null
encoding:
description:
- Encoding of the database
required: false
default: null
state:
description:
- The database state
...
...
@@ -143,7 +148,8 @@ def main():
template
=
dict
(
default
=
""
),
encoding
=
dict
(
default
=
""
),
state
=
dict
(
default
=
"present"
,
choices
=
[
"absent"
,
"present"
]),
)
),
supports_check_mode
=
True
)
if
not
postgresqldb_found
:
...
...
@@ -182,10 +188,15 @@ def main():
module
.
fail_json
(
msg
=
"unable to connect to database:
%
s"
%
e
)
try
:
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
,
db
=
db
)
if
state
==
"absent"
:
changed
=
db_delete
(
cursor
,
db
)
elif
state
==
"present"
:
changed
=
db_create
(
cursor
,
db
,
owner
,
template
,
encoding
)
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"Database query failed:
%
s"
%
e
)
...
...
library/postgresql_user
View file @
621eb5ec
...
...
@@ -375,8 +375,10 @@ def main():
port
=
dict
(
default
=
'5432'
),
fail_on_user
=
dict
(
default
=
'yes'
),
role_attr_flags
=
dict
(
default
=
''
)
)
),
supports_check_mode
=
True
)
user
=
module
.
params
[
"user"
]
password
=
module
.
params
[
"password"
]
state
=
module
.
params
[
"state"
]
...
...
@@ -412,17 +414,34 @@ def main():
kw
=
dict
(
user
=
user
)
changed
=
False
user_removed
=
False
if
state
==
"present"
:
if
user_exists
(
cursor
,
user
):
if
module
.
check_mode
:
kw
[
'changed'
]
=
True
module
.
exit_json
(
**
kw
)
changed
=
user_alter
(
cursor
,
user
,
password
,
role_attr_flags
)
else
:
if
password
is
None
:
msg
=
"password parameter required when adding a user"
module
.
fail_json
(
msg
=
msg
)
if
module
.
check_mode
:
kw
[
'changed'
]
=
True
module
.
exit_json
(
**
kw
)
changed
=
user_add
(
cursor
,
user
,
password
,
role_attr_flags
)
changed
=
grant_privileges
(
cursor
,
user
,
privs
)
or
changed
else
:
if
user_exists
(
cursor
,
user
):
if
module
.
check_mode
:
kw
[
'changed'
]
=
True
kw
[
'user_removed'
]
=
True
module
.
exit_json
(
**
kw
)
changed
=
revoke_privileges
(
cursor
,
user
,
privs
)
user_removed
=
user_delete
(
cursor
,
user
)
changed
=
changed
or
user_removed
...
...
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