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
507e4939
Commit
507e4939
authored
Feb 10, 2013
by
Chris Hoffman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating how to run commands in check mode
parent
ca3b8228
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
26 deletions
+24
-26
library/rabbitmq_plugin
+5
-3
library/rabbitmq_user
+19
-23
No files found.
library/rabbitmq_plugin
View file @
507e4939
...
...
@@ -57,9 +57,11 @@ class RabbitMqPlugins(object):
self
.
_rabbitmq_plugins
=
module
.
get_bin_path
(
'rabbitmq-plugins'
,
True
)
def
_exec
(
self
,
args
,
run_in_check_mode
=
False
):
cmd
=
[
self
.
_rabbitmq_plugins
]
rc
,
out
,
err
=
self
.
module
.
run_command
(
cmd
+
args
,
check_rc
=
True
)
return
out
.
splitlines
()
if
not
self
.
module
.
check_mode
or
(
self
.
module
.
check_mode
and
run_in_check_mode
):
cmd
=
[
self
.
_rabbitmq_plugins
]
rc
,
out
,
err
=
self
.
module
.
run_command
(
cmd
+
args
,
check_rc
=
True
)
return
out
.
splitlines
()
return
list
()
def
get_all
(
self
):
return
self
.
_exec
([
'list'
,
'-E'
,
'-m'
],
True
)
...
...
library/rabbitmq_user
View file @
507e4939
...
...
@@ -108,13 +108,15 @@ class RabbitMqUser(object):
self
.
_permissions
=
None
self
.
_rabbitmqctl
=
module
.
get_bin_path
(
'rabbitmqctl'
,
True
)
def
_exec
(
self
,
args
):
cmd
=
[
self
.
_rabbitmqctl
,
'-q'
]
rc
,
out
,
err
=
self
.
module
.
run_command
(
cmd
+
args
,
check_rc
=
True
)
return
out
.
splitlines
()
def
_exec
(
self
,
args
,
run_in_check_mode
=
False
):
if
not
self
.
module
.
check_mode
or
(
self
.
module
.
check_mode
and
run_in_check_mode
):
cmd
=
[
self
.
_rabbitmqctl
,
'-q'
]
rc
,
out
,
err
=
self
.
module
.
run_command
(
cmd
+
args
,
check_rc
=
True
)
return
out
.
splitlines
()
return
list
()
def
get
(
self
):
users
=
self
.
_exec
([
'list_users'
])
users
=
self
.
_exec
([
'list_users'
]
,
True
)
for
user_tag
in
users
:
user
,
tags
=
user_tag
.
split
(
'
\t
'
)
...
...
@@ -129,13 +131,11 @@ class RabbitMqUser(object):
self
.
_tags
=
list
()
self
.
_permissions
=
self
.
_get_permissions
()
return
True
return
False
def
_get_permissions
(
self
):
perms_out
=
self
.
_exec
([
'list_user_permissions'
,
self
.
username
])
perms_out
=
self
.
_exec
([
'list_user_permissions'
,
self
.
username
]
,
True
)
for
perm
in
perms_out
:
vhost
,
configure_priv
,
write_priv
,
read_priv
=
perm
.
split
(
'
\t
'
)
...
...
@@ -145,27 +145,23 @@ class RabbitMqUser(object):
return
dict
()
def
add
(
self
):
if
not
self
.
module
.
check_mode
:
self
.
_exec
([
'add_user'
,
self
.
username
,
self
.
password
])
self
.
_exec
([
'add_user'
,
self
.
username
,
self
.
password
])
def
delete
(
self
):
if
not
self
.
module
.
check_mode
:
self
.
_exec
([
'delete_user'
,
self
.
username
])
self
.
_exec
([
'delete_user'
,
self
.
username
])
def
set_tags
(
self
):
if
not
self
.
module
.
check_mode
:
self
.
_exec
([
'set_user_tags'
,
self
.
username
]
+
self
.
tags
)
self
.
_exec
([
'set_user_tags'
,
self
.
username
]
+
self
.
tags
)
def
set_permissions
(
self
):
if
not
self
.
module
.
check_mode
:
cmd
=
[
'set_permissions'
]
cmd
.
append
(
'-p'
)
cmd
.
append
(
self
.
permissions
[
'vhost'
])
cmd
.
append
(
self
.
username
)
cmd
.
append
(
self
.
permissions
[
'configure_priv'
])
cmd
.
append
(
self
.
permissions
[
'write_priv'
])
cmd
.
append
(
self
.
permissions
[
'read_priv'
])
self
.
_exec
(
cmd
)
cmd
=
[
'set_permissions'
]
cmd
.
append
(
'-p'
)
cmd
.
append
(
self
.
permissions
[
'vhost'
])
cmd
.
append
(
self
.
username
)
cmd
.
append
(
self
.
permissions
[
'configure_priv'
])
cmd
.
append
(
self
.
permissions
[
'write_priv'
])
cmd
.
append
(
self
.
permissions
[
'read_priv'
])
self
.
_exec
(
cmd
)
def
has_tags_modifications
(
self
):
return
set
(
self
.
tags
)
!=
set
(
self
.
_tags
)
...
...
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