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
b869f76e
Commit
b869f76e
authored
Jun 21, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow deb package installation via with_items
Fixes #7863
parent
70abc6f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
40 deletions
+51
-40
library/packaging/apt
+51
-40
No files found.
library/packaging/apt
View file @
b869f76e
...
...
@@ -291,50 +291,61 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
else:
return (True, dict(changed=False))
def install_deb(m, deb
file
, cache, force, install_recommends, dpkg_options):
def install_deb(m, deb
s
, cache, force, install_recommends, dpkg_options):
changed=False
pkg = apt.debfile.DebPackage(debfile)
# Check if it'
s
already
installed
if
pkg
.
compare_to_version_in_cache
()
==
pkg
.
VERSION_SAME
:
m
.
exit_json
(
changed
=
False
)
#
Check
if
package
is
installable
if
not
pkg
.
check
():
m
.
fail_json
(
msg
=
pkg
.
_failure_string
)
(
success
,
retvals
)
=
install
(
m
=
m
,
pkgspec
=
pkg
.
missing_deps
,
cache
=
cache
,
install_recommends
=
install_recommends
,
dpkg_options
=
expand_dpkg_options
(
dpkg_options
))
if
not
success
:
m
.
fail_json
(**
retvals
)
changed
=
retvals
[
'changed'
]
options
=
' '
.
join
([
"--%s"
%
x
for
x
in
dpkg_options
.
split
(
","
)])
if
m
.
check_mode
:
options
+=
" --simulate"
if
force
:
options
+=
" --force-yes"
deps_to_install = []
pkgs_to_install = []
for deb_file in debs.split('
,
'):
pkg = apt.debfile.DebPackage(deb_file)
# Check if it'
s
already
installed
if
pkg
.
compare_to_version_in_cache
()
==
pkg
.
VERSION_SAME
:
continue
#
Check
if
package
is
installable
if
not
pkg
.
check
():
m
.
fail_json
(
msg
=
pkg
.
_failure_string
)
#
add
any
missing
deps
to
the
list
of
deps
we
need
#
to
install
so
they
're all done in one shot
deps_to_install.extend(pkg.missing_deps)
# and add this deb to the list of packages to install
pkgs_to_install.append(deb_file)
# install the deps through apt
retvals = {}
if len(deps_to_install) > 0:
(success, retvals) = install(m=m, pkgspec=deps_to_install, cache=cache,
install_recommends=install_recommends,
dpkg_options=expand_dpkg_options(dpkg_options))
if not success:
m.fail_json(**retvals)
changed = retvals.get('
changed
', False)
if len(pkgs_to_install) > 0:
options = '
'.join(["--%s"% x for x in dpkg_options.split(",")])
if m.check_mode:
options += " --simulate"
if force:
options += " --force-yes"
cmd
=
"dpkg %s -i %s"
%
(
options
,
debfile
)
rc
,
out
,
err
=
m
.
run_command
(
cmd
)
cmd = "dpkg %s -i %s" % (options, " ".join(pkgs_to_install))
rc, out, err = m.run_command(cmd)
if "stdout" in retvals:
stdout = retvals["stdout"] + out
else:
stdout = out
if "stderr" in retvals:
stderr = retvals["stderr"] + err
else:
stderr = err
if
"stdout"
in
retvals
:
stdout
=
retvals
[
"stdout"
]
+
out
else
:
stdout
=
out
if
"stderr"
in
retvals
:
stderr
=
retvals
[
"stderr"
]
+
err
else
:
stderr
=
err
if
rc
==
0
:
m
.
exit_json
(
changed
=
True
,
stdout
=
stdout
,
stderr
=
stderr
)
if rc == 0:
m.exit_json(changed=True, stdout=stdout, stderr=stderr)
else:
m.fail_json(msg="%s failed" % cmd, stdout=stdout, stderr=stderr)
else:
m
.
fail_json
(
msg
=
"%s failed"
%
cmd
,
stdout
=
stdout
,
stderr
=
stderr
)
m.
exit_json(changed=changed, stdout=retvals.get('
stdout
',''), stderr=retvals.get('
stderr
','')
)
def remove(m, pkgspec, cache, purge=False,
dpkg_options=expand_dpkg_options(DPKG_OPTIONS)):
...
...
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