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
6b92b69f
Commit
6b92b69f
authored
Oct 18, 2012
by
Stijn Opheide
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the GRANT privilege for a mysql user (WITH GRANT OPTION)
parent
f1f44843
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
library/mysql_user
+8
-2
No files found.
library/mysql_user
View file @
6b92b69f
...
@@ -170,11 +170,13 @@ def privileges_get(cursor, user,host):
...
@@ -170,11 +170,13 @@ def privileges_get(cursor, user,host):
cursor
.
execute
(
"SHOW GRANTS FOR
%
s@
%
s"
,
(
user
,
host
))
cursor
.
execute
(
"SHOW GRANTS FOR
%
s@
%
s"
,
(
user
,
host
))
grants
=
cursor
.
fetchall
()
grants
=
cursor
.
fetchall
()
for
grant
in
grants
:
for
grant
in
grants
:
res
=
re
.
match
(
"GRANT
\
(.+)
\
ON
\
(.+)
\
TO"
,
grant
[
0
])
res
=
re
.
match
(
"GRANT
\
(.+)
\
ON
\
(.+)
\
TO
\
'.+'@'.+'[
\
IDENTIFIED
\
BY
\
PASSWORD
\
'.+']?
\
?(.*)
"
,
grant
[
0
])
if
res
is
None
:
if
res
is
None
:
module
.
fail_json
(
msg
=
"unable to parse the MySQL grant string"
)
module
.
fail_json
(
msg
=
"unable to parse the MySQL grant string"
)
privileges
=
res
.
group
(
1
)
.
split
(
", "
)
privileges
=
res
.
group
(
1
)
.
split
(
", "
)
privileges
=
[
'ALL'
if
x
==
'ALL PRIVILEGES'
else
x
for
x
in
privileges
]
privileges
=
[
'ALL'
if
x
==
'ALL PRIVILEGES'
else
x
for
x
in
privileges
]
if
res
.
group
(
3
)
==
"WITH GRANT OPTION"
:
privileges
.
append
(
'GRANT'
)
db
=
res
.
group
(
2
)
.
replace
(
'`'
,
''
)
db
=
res
.
group
(
2
)
.
replace
(
'`'
,
''
)
output
[
db
]
=
privileges
output
[
db
]
=
privileges
return
output
return
output
...
@@ -205,8 +207,12 @@ def privileges_revoke(cursor, user,host,db_table):
...
@@ -205,8 +207,12 @@ def privileges_revoke(cursor, user,host,db_table):
cursor
.
execute
(
query
)
cursor
.
execute
(
query
)
def
privileges_grant
(
cursor
,
user
,
host
,
db_table
,
priv
):
def
privileges_grant
(
cursor
,
user
,
host
,
db_table
,
priv
):
priv_string
=
","
.
join
(
priv
)
priv_string
=
","
.
join
(
filter
(
lambda
x
:
x
!=
'GRANT'
,
priv
))
query
=
"GRANT
%
s ON
%
s TO '
%
s'@'
%
s'"
%
(
priv_string
,
db_table
,
user
,
host
)
query
=
"GRANT
%
s ON
%
s TO '
%
s'@'
%
s'"
%
(
priv_string
,
db_table
,
user
,
host
)
if
'GRANT'
in
priv
:
query
=
query
+
" WITH GRANT OPTION"
cursor
.
execute
(
query
)
cursor
.
execute
(
query
)
def
load_mycnf
():
def
load_mycnf
():
...
...
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