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
91d31d81
Commit
91d31d81
authored
Aug 02, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #761 from skvidal/devel
redo of yum module - uses more system calls but should handle
parents
4fedb17e
c91befda
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
282 additions
and
179 deletions
+282
-179
library/yum
+282
-179
No files found.
library/yum
View file @
91d31d81
...
@@ -18,82 +18,109 @@
...
@@ -18,82 +18,109 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
#
import
yum
import
datetime
import
traceback
import
traceback
import
os
def
yum_base
(
conf_file
=
None
,
cachedir
=
False
):
def_qf
=
"
%
{name}-
%
{version}-
%
{release}.
%
{arch}"
my
=
yum
.
YumBase
()
my
.
preconf
.
debuglevel
=
0
def
is_installed
(
repoq
,
pkgspec
,
qf
=
def_qf
):
if
conf_file
and
os
.
path
.
exists
(
conf_file
):
cmd
=
repoq
+
"--disablerepo=
\
* --pkgnarrow=installed --qf '
%
s'
%
s "
%
(
qf
,
pkgspec
)
my
.
preconf
.
fn
=
conf_file
rc
,
out
,
err
=
run
(
cmd
)
if
cachedir
:
if
rc
==
0
:
if
hasattr
(
my
,
'setCacheDir'
):
return
[
p
for
p
in
out
.
split
(
'
\n
'
)
if
p
.
strip
()
]
my
.
setCacheDir
()
else
:
return
[]
cachedir
=
yum
.
misc
.
getCacheDir
()
my
.
repos
.
setCacheDir
(
cachedir
)
def
is_available
(
repoq
,
pkgspec
,
qf
=
def_qf
):
my
.
conf
.
cache
=
0
cmd
=
repoq
+
"--qf '
%
s'
%
s "
%
(
qf
,
pkgspec
)
rc
,
out
,
err
=
run
(
cmd
)
if
rc
==
0
:
return
[
p
for
p
in
out
.
split
(
'
\n
'
)
if
p
.
strip
()
]
return
[]
def
is_update
(
repoq
,
pkgspec
,
qf
=
def_qf
):
cmd
=
repoq
+
"--pkgnarrow=updates --qf '
%
s'
%
s "
%
(
qf
,
pkgspec
)
rc
,
out
,
err
=
run
(
cmd
)
if
rc
==
0
:
return
set
([
p
for
p
in
out
.
split
(
'
\n
'
)
if
p
.
strip
()
])
return
[]
def
what_provides
(
repoq
,
req_spec
,
qf
=
def_qf
):
cmd
=
repoq
+
"--qf '
%
s' --whatprovides
%
s"
%
(
qf
,
req_spec
)
rc
,
out
,
err
=
run
(
cmd
)
ret
=
[]
if
rc
==
0
:
ret
=
set
([
p
for
p
in
out
.
split
(
'
\n
'
)
if
p
.
strip
()
])
return
my
return
ret
def
pkg_to_dict
(
po
):
def
local_nvra
(
path
):
"""return nvra of a local rpm passed in"""
cmd
=
"/bin/rpm -qp --qf='
%%
{name}-
%%
{version}-
%%
{release}.
%%
{arch}
\n
'
%
s'"
%
path
rc
,
out
,
err
=
run
(
cmd
)
if
rc
!=
0
:
return
None
nvra
=
out
.
split
(
'
\n
'
)[
0
]
return
nvra
def
pkg_to_dict
(
pkgstr
):
if
pkgstr
.
strip
():
n
,
e
,
v
,
r
,
a
,
repo
=
pkgstr
.
split
(
'|'
)
else
:
return
{
'error_parsing'
:
pkgstr
}
d
=
{
d
=
{
'name'
:
po
.
name
,
'name'
:
n
,
'arch'
:
po
.
arch
,
'arch'
:
a
,
'epoch'
:
po
.
epoch
,
'epoch'
:
e
,
'release'
:
po
.
release
,
'release'
:
r
,
'version'
:
po
.
version
,
'version'
:
v
,
'repo'
:
repo
,
'nevra'
:
'
%
s:
%
s-
%
s-
%
s.
%
s'
%
(
e
,
n
,
v
,
r
,
a
)
}
}
if
type
(
po
)
==
yum
.
rpmsack
.
RPMInstalledPackage
:
if
repo
==
'installed'
:
d
[
'yumstate'
]
=
'installed'
d
[
'yumstate'
]
=
'installed'
d
[
'repo'
]
=
'installed'
else
:
else
:
d
[
'yumstate'
]
=
'available'
d
[
'yumstate'
]
=
'available'
d
[
'repo'
]
=
po
.
repoid
return
d
def
repolist
(
repoq
,
qf
=
"
%
{repoid}"
):
cmd
=
repoq
+
"--qf '
%
s' -a"
%
(
qf
)
rc
,
out
,
err
=
run
(
cmd
)
ret
=
[]
if
rc
==
0
:
ret
=
set
([
p
for
p
in
out
.
split
(
'
\n
'
)
if
p
.
strip
()
])
if
hasattr
(
po
,
'ui_from_repo'
):
return
ret
d
[
'repo'
]
=
po
.
ui_from_repo
if
hasattr
(
po
,
'ui_nevra'
):
d
[
'_nevra'
]
=
po
.
ui_nevra
else
:
d
[
'_nevra'
]
=
'
%
s-
%
s-
%
s.
%
s'
%
(
po
.
name
,
po
.
version
,
po
.
release
,
po
.
arch
)
def
list_stuff
(
conf_file
,
stuff
):
qf
=
"
%
{name}|
%
{epoch}|
%
{version}|
%
{release}|
%
{arch}|
%
{repoid}"
repoq
=
'/usr/bin/repoquery --plugins --quiet -q '
if
conf_file
and
os
.
path
.
exists
(
conf_file
):
repoq
=
'/usr/bin/repoquery -c
%
s --plugins --quiet -q '
%
conf_file
return
d
def
list_stuff
(
my
,
stuff
):
# FIXME - there are potential tracebacks that could occur here
# need some more catching for them so we can see what happened
if
stuff
==
'installed'
:
if
stuff
==
'installed'
:
return
[
pkg_to_dict
(
p
o
)
for
po
in
my
.
rpmdb
]
return
[
pkg_to_dict
(
p
)
for
p
in
is_installed
(
repoq
,
'-a'
,
qf
=
qf
)
if
p
.
strip
()
]
elif
stuff
==
'updates'
:
elif
stuff
==
'updates'
:
return
[
pkg_to_dict
(
po
)
for
return
[
pkg_to_dict
(
p
)
for
p
in
is_update
(
repoq
,
'-a'
,
qf
=
qf
)
if
p
.
strip
()
]
po
in
my
.
doPackageLists
(
pkgnarrow
=
'updates'
)
.
updates
]
elif
stuff
==
'available'
:
elif
stuff
==
'available'
:
return
[
pkg_to_dict
(
p
o
)
for
po
in
my
.
pkgSack
]
return
[
pkg_to_dict
(
p
)
for
p
in
is_available
(
repoq
,
'-a'
,
qf
=
qf
)
if
p
.
strip
()
]
elif
stuff
==
'repos'
:
elif
stuff
==
'repos'
:
r
=
[]
return
[
dict
(
repoid
=
name
,
state
=
'enabled'
)
for
name
in
repolist
(
repoq
)
if
name
.
strip
()
]
for
repo
in
my
.
repos
.
repos
.
values
():
t
=
{}
s
=
'disabled'
if
repo
.
enabled
:
s
=
'enabled'
t
[
repo
.
id
]
=
s
r
.
append
(
t
)
return
r
else
:
else
:
e
,
m
,
u
=
my
.
rpmdb
.
matchPackageNames
([
stuff
])
return
[
pkg_to_dict
(
p
)
for
p
in
is_installed
(
repoq
,
stuff
,
qf
=
qf
)
+
is_available
(
repoq
,
stuff
,
qf
=
qf
)
if
p
.
strip
()
]
p
=
e
+
m
e
,
m
,
u
=
my
.
pkgSack
.
matchPackageNames
([
stuff
])
p
=
p
+
e
+
m
return
[
pkg_to_dict
(
po
)
for
po
in
p
]
def
run
_yum
(
command
):
def
run
(
command
):
try
:
try
:
cmd
=
subprocess
.
Popen
(
command
,
shell
=
True
,
cmd
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
...
@@ -106,7 +133,7 @@ def run_yum(command):
...
@@ -106,7 +133,7 @@ def run_yum(command):
rc
=
1
rc
=
1
err
=
traceback
.
format_exc
()
err
=
traceback
.
format_exc
()
out
=
''
out
=
''
if
out
is
None
:
if
out
is
None
:
out
=
''
out
=
''
if
err
is
None
:
if
err
is
None
:
...
@@ -116,119 +143,176 @@ def run_yum(command):
...
@@ -116,119 +143,176 @@ def run_yum(command):
return
rc
,
out
,
err
return
rc
,
out
,
err
def
ensure
(
my
,
state
,
pkgspec
):
yumconf
=
my
.
conf
.
config_file_path
def
install
(
module
,
items
,
repoq
,
yum_basecmd
):
res
=
{}
res
=
{}
if
state
in
[
'installed'
,
'present'
]:
res
[
'results'
]
=
''
# check if pkgspec is installed
res
[
'msg'
]
=
''
if
re
.
search
(
'[></=]'
,
pkgspec
):
res
[
'rc'
]
=
0
try
:
res
[
'failed'
]
=
False
pkgs
=
my
.
returnInstalledPackagesByDep
(
pkgspec
)
res
[
'changed'
]
=
False
except
yum
.
Errors
.
YumBaseError
:
pkgs
=
None
for
spec
in
items
:
else
:
pkg
=
None
e
,
m
,
u
=
my
.
rpmdb
.
matchPackageNames
([
pkgspec
])
pkgs
=
e
+
m
# check if pkgspec is installed (if possible for idempotence)
# localpkg
if
pkgs
:
if
spec
.
endswith
(
'.rpm'
):
return
{
'changed'
:
False
}
# get the pkg name-v-r.arch
nvra
=
local_nvra
(
spec
)
# if not see if it is available
# look for them in the rpmdb
if
re
.
search
(
'[></=]'
,
pkgspec
):
if
is_installed
(
repoq
,
nvra
):
try
:
# if they are there, skip it
pkgs
=
my
.
returnPackagesByDep
(
pkgspec
)
continue
except
yum
.
Errors
.
YumBaseError
:
pkg
=
spec
pkgs
=
None
#groups :(
elif
spec
.
startswith
(
'@'
):
# complete wild ass guess b/c it's a group
pkg
=
spec
# range requires or file-requires or pkgname :(
else
:
else
:
e
,
m
,
u
=
my
.
pkgSack
.
matchPackageNames
([
pkgspec
])
# look up what pkgs provide this
pkgs
=
e
+
m
pkglist
=
what_provides
(
repoq
,
spec
)
if
not
pkglist
:
if
not
pkgs
:
res
[
'msg'
]
+=
"No Package matching '
%
s' found available, installed or updated"
%
spec
msg
=
"No Package matching
%
s available"
%
pkgspec
res
[
'failed'
]
=
True
return
{
'changed'
:
False
,
'failed'
:
True
,
'msg'
:
msg
}
module
.
exit_json
(
**
res
)
# if any of them are installed
# then nothing to do
found
=
False
for
this
in
pkglist
:
if
is_installed
(
repoq
,
this
):
found
=
True
res
[
'results'
]
+=
'
%
s providing
%
s is already installed
\n
'
%
(
this
,
spec
)
if
found
:
continue
# if not - then pass in the spec as what to install
# we could get here if nothing provides it but that's not
# the error we're catching here
pkg
=
spec
my
.
close
()
cmd
=
"
%
s install '
%
s'"
%
(
yum_basecmd
,
pkg
)
del
my
res
[
'results'
]
+=
"
\n
Installing
%
s
\n
"
%
pkg
cmd
=
"yum -c
%
s -d1 -y install '
%
s'"
%
(
yumconf
,
pkgspec
)
rc
,
out
,
err
=
run
(
cmd
)
rc
,
out
,
err
=
run_yum
(
cmd
)
# 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
rc
:
changed
=
False
res
[
'changed'
]
=
False
failed
=
True
res
[
'failed'
]
=
True
res
[
'rc'
]
=
rc
res
[
'results'
]
+=
out
res
[
'msg'
]
+=
err
else
:
else
:
changed
=
True
res
[
'changed'
]
=
True
failed
=
False
res
[
'failed'
]
=
False
res
[
'rc'
]
=
0
res
[
'results'
]
+=
out
res
[
'msg'
]
+=
err
module
.
exit_json
(
**
res
)
res
[
'changed'
]
=
changed
if
failed
:
def
remove
(
module
,
items
,
repoq
,
yum_basecmd
):
res
[
'failed'
]
=
failed
res
=
{}
res
[
'msg'
]
=
err
res
[
'results'
]
=
''
res
[
'results'
]
=
out
res
[
'msg'
]
=
''
res
[
'changed'
]
=
False
return
res
res
[
'failed'
]
=
False
res
[
'rc'
]
=
0
if
state
in
[
'absent'
,
'removed'
]:
# check if pkgspec is installed
for
spec
in
items
:
# if not return {changed: False, failed=False }
pkg
=
None
# if so try to remove it:
# if successfull {changed:True, failed=False, results=stdout, errors=stderr }
# group remove - hope you like things dying!
# if fail {'changed':False, failed='True', results=stdout, errors=stderr }
if
spec
.
startswith
(
'@'
):
yumconf
=
my
.
conf
.
config_file_path
pkg
=
spec
if
re
.
search
(
'[></=]'
,
pkgspec
):
# req or pkgname remove
try
:
pkgs
=
my
.
returnInstalledPackagesByDep
(
pkgspec
)
except
yum
.
Errors
.
YumBaseError
:
pkgs
=
None
else
:
else
:
e
,
m
,
u
=
my
.
rpmdb
.
matchPackageNames
([
pkgspec
])
pkglist
=
what_provides
(
repoq
,
spec
)
pkgs
=
e
+
m
if
not
pkglist
:
res
[
'msg'
]
+=
"No Package matching '
%
s' found available, installed or updated"
%
spec
res
[
'failed'
]
=
True
module
.
exit_json
(
**
res
)
found
=
False
for
this
in
pkglist
:
if
is_installed
(
repoq
,
this
):
found
=
True
if
not
found
:
continue
pkg
=
spec
if
not
pkgs
:
cmd
=
"
%
s remove '
%
s'"
%
(
yum_basecmd
,
pkg
)
return
{
'changed'
:
False
}
rc
,
out
,
err
=
run
(
cmd
)
my
.
close
()
del
my
cmd
=
"yum -c
%
s -d1 -y remove '
%
s'"
%
(
yumconf
,
pkgspec
)
rc
,
out
,
err
=
run_yum
(
cmd
)
# FIXME if we ran the remove - check to make sure it actually removed :(
# FIXME if we ran the remove - check to make sure it actually removed :(
# look for the pkg in the rpmdb
# look for the pkg in the rpmdb - this is notoriously hard for groups :(
if
rc
:
if
rc
!=
0
:
changed
=
False
res
[
'changed'
]
=
False
failed
=
True
res
[
'failed'
]
=
True
res
[
'rc'
]
=
rc
res
[
'results'
]
+=
out
res
[
'msg'
]
+=
err
else
:
else
:
changed
=
True
res
[
'changed'
]
=
True
failed
=
False
res
[
'failed'
]
=
False
res
[
'rc'
]
=
0
res
[
'changed'
]
=
changed
res
[
'results'
]
+=
out
res
[
'msg'
]
+=
err
module
.
exit_json
(
**
res
)
if
failed
:
def
latest
(
module
,
items
,
repoq
,
yum_basecmd
):
res
[
'failed'
]
=
failed
res
=
{}
res
[
'msg'
]
=
err
res
[
'results'
]
=
''
res
[
'results'
]
=
out
res
[
'msg'
]
=
''
res
[
'changed'
]
=
False
res
[
'failed'
]
=
False
res
[
'rc'
]
=
0
for
spec
in
items
:
pkg
=
None
return
res
# groups, again
if
spec
.
startswith
(
'@'
):
if
state
==
'latest'
:
pkg
=
spec
updates
=
my
.
doPackageLists
(
pkgnarrow
=
'updates'
,
patterns
=
[
pkgspec
])
.
updates
# dep/pkgname - find it
# sucks but this is for rhel5 - won't matter for rhel6 or fedora or whatnot
e
,
m
,
u
=
yum
.
parsePackages
(
updates
,
[
pkgspec
],
casematch
=
True
)
updates
=
e
+
m
avail
=
my
.
doPackageLists
(
pkgnarrow
=
'available'
,
patterns
=
[
pkgspec
])
.
available
if
not
updates
and
not
avail
:
if
not
my
.
doPackageLists
(
pkgnarrow
=
'installed'
,
patterns
=
[
pkgspec
])
.
installed
:
msg
=
"No Package matching '
%
s' found available, installed or updated"
%
pkgspec
return
{
'changed'
:
False
,
'failed'
:
True
,
'msg'
:
msg
}
return
{
'changed'
:
False
,}
# we have something in updates or available
if
not
updates
:
cmd
=
"yum -c
%
s -d1 -y install '
%
s'"
%
(
yumconf
,
pkgspec
)
else
:
else
:
cmd
=
"yum -c
%
s -d1 -y update '
%
s'"
%
(
yumconf
,
pkgspec
)
pkglist
=
what_provides
(
repoq
,
spec
)
rc
,
out
,
err
=
run_yum
(
cmd
)
if
not
pkglist
:
res
[
'msg'
]
+=
"No Package matching '
%
s' found available, installed or updated"
%
spec
res
[
'failed'
]
=
True
module
.
exit_json
(
**
res
)
found
=
False
nothing_to_do
=
False
can_be_installed
=
True
for
this
in
pkglist
:
if
is_installed
(
repoq
,
this
):
if
is_update
(
repoq
,
this
):
found
=
True
else
:
nothing_to_do
=
True
if
nothing_to_do
:
res
[
'results'
]
+=
"All packages providing
%
s are up to date"
%
spec
continue
if
not
found
:
basecmd
=
'install'
else
:
basecmd
=
'update'
pkg
=
spec
cmd
=
"
%
s
%
s '
%
s'"
%
(
yum_basecmd
,
basecmd
,
pkg
)
rc
,
out
,
err
=
run
(
cmd
)
# 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
...
@@ -240,23 +324,49 @@ def ensure(my, state, pkgspec):
...
@@ -240,23 +324,49 @@ def ensure(my, state, pkgspec):
failed
=
False
failed
=
False
res
[
'changed'
]
=
changed
if
rc
:
res
[
'changed'
]
=
False
res
[
'failed'
]
=
True
res
[
'rc'
]
=
rc
res
[
'results'
]
+=
out
res
[
'msg'
]
+=
err
else
:
res
[
'changed'
]
=
True
res
[
'failed'
]
=
False
res
[
'rc'
]
=
0
res
[
'results'
]
+=
out
res
[
'msg'
]
+=
err
module
.
exit_json
(
**
res
)
if
failed
:
res
[
'failed'
]
=
failed
res
[
'msg'
]
=
err
res
[
'results'
]
=
out
return
res
def
ensure
(
module
,
state
,
pkgspec
,
conf_file
):
res
=
{}
stdout
=
""
stderr
=
""
# take multiple args comma separated
items
=
[
pkgspec
]
if
pkgspec
.
find
(
','
)
!=
-
1
:
items
=
pkgspec
.
split
(
','
)
# should be caught by AnsibleModule argument_spec
yum_basecmd
=
'/usr/bin/yum -d1 -y '
return
dict
(
changed
=
False
,
failed
=
True
,
results
=
''
,
errors
=
"unexpected state:
%
s"
%
state
)
repoq
=
'/usr/bin/repoquery --plugins --quiet -q '
if
conf_file
and
os
.
path
.
exists
(
conf_file
):
yum_basecmd
=
'/usr/bin/yum -c
%
s -d1 -y'
%
conf_file
repoq
=
'/usr/bin/repoquery -c
%
s --plugins --quiet -q '
%
conf_file
if
state
in
[
'installed'
,
'present'
]:
install
(
module
,
items
,
repoq
,
yum_basecmd
)
elif
state
in
[
'removed'
,
'absent'
]:
remove
(
module
,
items
,
repoq
,
yum_basecmd
)
elif
state
==
'latest'
:
latest
(
module
,
items
,
repoq
,
yum_basecmd
)
def
update
(
args
):
# should be caught by AnsibleModule argument_spec
#generic update routine
return
dict
(
changed
=
False
,
failed
=
True
,
results
=
''
,
errors
=
'unexpected state'
)
pass
def
remove_only
(
pkgspec
):
def
remove_only
(
pkgspec
):
# remove this pkg and only this pkg - fail if it will require more to remove
# remove this pkg and only this pkg - fail if it will require more to remove
...
@@ -276,25 +386,22 @@ def main():
...
@@ -276,25 +386,22 @@ def main():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
argument_spec
=
dict
(
argument_spec
=
dict
(
pkg
=
dict
(
aliases
=
[
'name'
,
'package'
]),
pkg
=
dict
(
aliases
=
[
'name'
]),
# removed==absent, installed==present, these are accepted as aliases
# removed==absent, installed==present, these are accepted as aliases
state
=
dict
(
default
=
'installed'
,
choices
=
[
'absent'
,
'present'
,
'installed'
,
'removed'
,
'latest'
]),
state
=
dict
(
default
=
'installed'
,
choices
=
[
'absent'
,
'present'
,
'installed'
,
'removed'
,
'latest'
]),
list
=
dict
(
choices
=
[
'installed'
,
'updates'
,
'available'
,
'repos'
,
'pkgspec'
]),
list
=
dict
(
choices
=
[
'installed'
,
'updates'
,
'available'
,
'repos'
,
'pkgspec'
]),
conf_file
=
dict
(
)
conf_file
=
dict
(
default
=
None
),
)
)
)
)
params
=
module
.
params
params
=
module
.
params
if
params
[
'list'
]
and
params
[
'pkg'
]:
if
params
[
'list'
]
and
params
[
'pkg'
]:
module
.
fail_json
(
msg
=
"expected 'list=' or 'name=', but not both"
)
module
.
fail_json
(
msg
=
"expected 'list=' or 'name=', but not both"
)
if
params
[
'list'
]:
if
params
[
'list'
]:
try
:
results
=
dict
(
results
=
list_stuff
(
params
[
'conf_file'
],
params
[
'list'
]))
my
=
yum_base
(
conf_file
=
params
[
'conf_file'
],
cachedir
=
True
)
results
=
dict
(
results
=
list_stuff
(
my
,
params
[
'list'
]))
except
Exception
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
module
.
exit_json
(
**
results
)
module
.
exit_json
(
**
results
)
else
:
else
:
...
@@ -302,13 +409,9 @@ def main():
...
@@ -302,13 +409,9 @@ def main():
if
'pkg'
is
None
:
if
'pkg'
is
None
:
module
.
fail_json
(
msg
=
"expected 'list=' or 'name='"
)
module
.
fail_json
(
msg
=
"expected 'list=' or 'name='"
)
else
:
else
:
try
:
state
=
params
[
'state'
]
my
=
yum_base
(
conf_file
=
params
[
'conf_file'
],
cachedir
=
True
)
res
=
ensure
(
module
,
state
,
pkg
,
params
[
'conf_file'
])
state
=
params
[
'state'
]
module
.
fail_json
(
msg
=
"we should never get here unless this all failed"
,
**
res
)
results
=
ensure
(
my
,
state
,
pkg
)
except
Exception
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
module
.
exit_json
(
**
results
)
# this is magic, see lib/ansible/module_common.py
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
...
...
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