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
03f4b0f9
Commit
03f4b0f9
authored
Nov 08, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1560 from dagwieers/module-output-consistency
Make module output more consistent wrt. changed/failed
parents
cbff0213
fe0c70fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
40 deletions
+24
-40
lib/ansible/module_common.py
+2
-0
library/yum
+22
-40
No files found.
lib/ansible/module_common.py
View file @
03f4b0f9
...
@@ -594,6 +594,8 @@ class AnsibleModule(object):
...
@@ -594,6 +594,8 @@ class AnsibleModule(object):
def exit_json(self, **kwargs):
def exit_json(self, **kwargs):
''' return from the module, without error '''
''' return from the module, without error '''
self.add_path_info(kwargs)
self.add_path_info(kwargs)
if not kwargs.has_key('changed'):
kwargs['changed'] = False
print self.jsonify(kwargs)
print self.jsonify(kwargs)
sys.exit(0)
sys.exit(0)
...
...
library/yum
View file @
03f4b0f9
...
@@ -405,19 +405,16 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
...
@@ -405,19 +405,16 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
cmd
=
yum_basecmd
+
[
'install'
,
pkg
]
cmd
=
yum_basecmd
+
[
'install'
,
pkg
]
rc
,
out
,
err
=
run
(
cmd
)
rc
,
out
,
err
=
run
(
cmd
)
res
[
'rc'
]
+=
rc
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
# FIXME - if we did an install - go and check the rpmdb to see if it actually installed
# FIXME - if we did an install - go and check the rpmdb to see if it actually installed
# look for the pkg in rpmdb
# look for the pkg in rpmdb
# look for the pkg via obsoletes
# look for the pkg via obsoletes
if
rc
:
if
not
rc
:
res
[
'changed'
]
=
False
res
[
'rc'
]
=
rc
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
else
:
res
[
'changed'
]
=
True
res
[
'changed'
]
=
True
res
[
'rc'
]
=
0
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
module
.
exit_json
(
**
res
)
module
.
exit_json
(
**
res
)
...
@@ -429,7 +426,6 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
...
@@ -429,7 +426,6 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
res
[
'msg'
]
=
''
res
[
'msg'
]
=
''
res
[
'changed'
]
=
False
res
[
'changed'
]
=
False
res
[
'rc'
]
=
0
res
[
'rc'
]
=
0
res
[
'failed'
]
=
False
for
pkg
in
items
:
for
pkg
in
items
:
is_group
=
False
is_group
=
False
...
@@ -445,6 +441,15 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
...
@@ -445,6 +441,15 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
cmd
=
yum_basecmd
+
[
"remove"
,
pkg
]
cmd
=
yum_basecmd
+
[
"remove"
,
pkg
]
rc
,
out
,
err
=
run
(
cmd
)
rc
,
out
,
err
=
run
(
cmd
)
res
[
'rc'
]
+=
rc
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
# compile the results into one batch. If anything is changed
# then mark changed
# at the end - if we've end up failed then fail out of the rest
# of the process
# at this point we should check to see if the pkg is no longer present
# at this point we should check to see if the pkg is no longer present
if
not
is_group
:
# we can't sensibly check for a group being uninstalled reliably
if
not
is_group
:
# we can't sensibly check for a group being uninstalled reliably
...
@@ -452,24 +457,11 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
...
@@ -452,24 +457,11 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
if
not
is_installed
(
module
,
repoq
,
pkg
,
conf_file
,
en_repos
=
en_repos
,
dis_repos
=
dis_repos
):
if
not
is_installed
(
module
,
repoq
,
pkg
,
conf_file
,
en_repos
=
en_repos
,
dis_repos
=
dis_repos
):
res
[
'changed'
]
=
True
res
[
'changed'
]
=
True
else
:
else
:
res
[
'failed'
]
=
True
module
.
fail_json
(
**
res
)
if
rc
!=
0
:
if
rc
!=
0
:
res
[
'failed'
]
=
True
# compile the results into one batch. If anything is changed
# then mark changed
# at the end - if we've end up failed then fail out of the rest
# of the process
res
[
'changed'
]
=
res
[
'changed'
]
or
False
res
[
'failed'
]
=
res
[
'failed'
]
or
False
res
[
'rc'
]
+=
rc
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
if
res
[
'failed'
]:
module
.
fail_json
(
**
res
)
module
.
fail_json
(
**
res
)
module
.
exit_json
(
**
res
)
module
.
exit_json
(
**
res
)
def
latest
(
module
,
items
,
repoq
,
yum_basecmd
,
conf_file
,
en_repos
,
dis_repos
):
def
latest
(
module
,
items
,
repoq
,
yum_basecmd
,
conf_file
,
en_repos
,
dis_repos
):
...
@@ -497,8 +489,7 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
...
@@ -497,8 +489,7 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
pkglist
=
what_provides
(
module
,
repoq
,
spec
,
conf_file
,
en_repos
=
en_repos
,
dis_repos
=
dis_repos
)
pkglist
=
what_provides
(
module
,
repoq
,
spec
,
conf_file
,
en_repos
=
en_repos
,
dis_repos
=
dis_repos
)
if
not
pkglist
:
if
not
pkglist
:
res
[
'msg'
]
+=
"No Package matching '
%
s' found available, installed or updated"
%
spec
res
[
'msg'
]
+=
"No Package matching '
%
s' found available, installed or updated"
%
spec
res
[
'failed'
]
=
True
module
.
fail_json
(
**
res
)
module
.
exit_json
(
**
res
)
nothing_to_do
=
True
nothing_to_do
=
True
for
this
in
pkglist
:
for
this
in
pkglist
:
...
@@ -519,26 +510,17 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
...
@@ -519,26 +510,17 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
cmd
=
yum_basecmd
+
[
basecmd
,
pkg
]
cmd
=
yum_basecmd
+
[
basecmd
,
pkg
]
rc
,
out
,
err
=
run
(
cmd
)
rc
,
out
,
err
=
run
(
cmd
)
res
[
'rc'
]
+=
rc
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
# FIXME if it is - update it and check to see if it applied
# FIXME if it is - update it and check to see if it applied
# check to see if there is no longer an update available for the pkgspec
# check to see if there is no longer an update available for the pkgspec
if
rc
:
changed
=
False
failed
=
True
else
:
changed
=
True
failed
=
False
if
rc
:
if
rc
:
res
[
'changed'
]
=
False
res
[
'failed'
]
=
True
res
[
'failed'
]
=
True
res
[
'rc'
]
=
rc
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
else
:
else
:
res
[
'changed'
]
=
True
res
[
'changed'
]
=
True
res
[
'rc'
]
=
0
res
[
'results'
]
.
append
(
out
)
res
[
'msg'
]
+=
err
module
.
exit_json
(
**
res
)
module
.
exit_json
(
**
res
)
...
...
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