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
c819f171
Commit
c819f171
authored
Apr 03, 2012
by
Matthew Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apt module bugfix
parent
02d5e831
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
library/apt
+7
-5
No files found.
library/apt
View file @
c819f171
...
@@ -67,21 +67,21 @@ def run_apt(command):
...
@@ -67,21 +67,21 @@ def run_apt(command):
def package_status(pkgspec, cache):
def package_status(pkgspec, cache):
try:
try:
pkg = cache[pkgspec]
pkg = cache[pkgspec]
except:
except:
fail_json(msg="No package matching '
%
s
' is available" % pkgspec)
fail_json(msg="No package matching '
%
s
' is available" % pkgspec)
return (pkg.is_installed, pkg.is_upgradable)
return (pkg.is_installed, pkg.is_upgradable)
def install(pkgspec, cache, upgrade=False):
def install(pkgspec, cache, upgrade=False):
(installed, upgradable) = package_status(pkgspec, cache)
(installed, upgradable) = package_status(pkgspec, cache)
if installed or not upgrade or not upgradable:
if (not installed) or (upgrade and upgradable):
return False
else:
cmd = "%s -q -y install '
%
s
'" % (APT, pkgspec)
cmd = "%s -q -y install '
%
s
'" % (APT, pkgspec)
rc, out, err = run_apt(cmd)
rc, out, err = run_apt(cmd)
if rc:
if rc:
json_fail(msg="'
apt
-
get
install
%
s
' failed: %s" % (pkgspec, err))
json_fail(msg="'
apt
-
get
install
%
s
' failed: %s" % (pkgspec, err))
return True
return True
else:
return False
def remove(pkgspec, cache, purge=False):
def remove(pkgspec, cache, purge=False):
(installed, upgradable) = package_status(pkgspec, cache)
(installed, upgradable) = package_status(pkgspec, cache)
...
@@ -128,7 +128,7 @@ if update_cache not in ['yes', 'no']:
...
@@ -128,7 +128,7 @@ if update_cache not in ['yes', 'no']:
if purge not in ['
yes
', '
no
']:
if purge not in ['
yes
', '
no
']:
fail_json(msg='
invalid
value
for
purge
(
requires
yes
or
no
--
default
is
no
)
')
fail_json(msg='
invalid
value
for
purge
(
requires
yes
or
no
--
default
is
no
)
')
if package is None and update
-
cache != '
yes
':
if package is None and update
_
cache != '
yes
':
fail_json(msg='
pkg
=
name
and
/
or
update
-
cache
=
yes
is
required
')
fail_json(msg='
pkg
=
name
and
/
or
update
-
cache
=
yes
is
required
')
cache = apt.Cache()
cache = apt.Cache()
...
@@ -136,6 +136,8 @@ cache = apt.Cache()
...
@@ -136,6 +136,8 @@ cache = apt.Cache()
if update_cache == '
yes
':
if update_cache == '
yes
':
cache.update()
cache.update()
cache.open()
cache.open()
if package == None:
exit_json(changed=False)
if state == '
latest
':
if state == '
latest
':
changed = install(package, cache, upgrade=True)
changed = install(package, cache, upgrade=True)
...
...
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