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
7a67145e
Commit
7a67145e
authored
Jul 30, 2012
by
Mark Theunissen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for apt module
parent
af3b0e3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
library/apt
+16
-16
No files found.
library/apt
View file @
7a67145e
...
...
@@ -19,7 +19,7 @@
import
traceback
#
added
to
stave
off
future
warnings
about
apt
api
import
warnings
;
import
warnings
;
warnings
.
filterwarnings
(
'ignore'
,
"apt API not stable yet"
,
FutureWarning
)
#
APT
related
constants
...
...
@@ -28,7 +28,7 @@ APT = "DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical %s" % APT_PATH
def
run_apt
(
command
):
try
:
cmd
=
subprocess
.
Popen
(
command
,
shell
=
True
,
cmd
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
cmd
.
communicate
()
except
(
OSError
,
IOError
),
e
:
...
...
@@ -58,13 +58,13 @@ def package_status(m, pkgname, version, cache):
if
version
:
try
:
return
pkg
.
is_installed
and
pkg
.
installed
.
version
==
version
,
False
except
AttributeError
:
except
AttributeError
:
#
assume
older
version
of
python
-
apt
is
installed
return
pkg
.
isInstalled
and
pkg
.
installedVersion
==
version
,
False
else
:
try
:
return
pkg
.
is_installed
,
pkg
.
is_upgradable
except
AttributeError
:
except
AttributeError
:
#
assume
older
version
of
python
-
apt
is
installed
return
pkg
.
isInstalled
,
pkg
.
isUpgradable
...
...
@@ -103,7 +103,7 @@ def remove(m, pkgspec, cache, purge=False):
if
rc
:
m
.
fail_json
(
msg
=
"'apt-get remove %s' failed: %s"
%
(
name
,
err
))
m
.
exit_json
(
changed
=
True
)
def
main
():
module
=
AnsibleModule
(
...
...
@@ -129,29 +129,29 @@ def main():
p
=
module
.
params
if
p
[
'package'
]
is
None
and
p
[
'update_cache'
]
!= 'yes':
module
.
fail_json
(
msg
=
'pkg=name and/or update_cache=yes is required'
)
install_recommends
=
module
.
boolean
(
p
[
'install_recommends'
])
cache
=
apt
.
Cache
()
if
p
[
'default_release'
]:
apt_pkg
.
config
[
'APT::Default-Release'
]
=
p
[
'default_release'
]
#
reopen
cache
w
/
modified
config
cache
.
open
(
progress
=
None
)
if
module
s
.
boolean
(
p
[
'update_cache'
])
if
module
.
boolean
(
p
[
'update_cache'
]):
cache
.
update
()
cache
.
open
(
progress
=
None
)
if
p
[
'package'
]
==
None
:
module
.
exit_json
(
changed
=
False
)
force_yes
=
module
s
.
boolean
(
p
[
'force'
])
force_yes
=
module
.
boolean
(
p
[
'force'
])
if
p
[
'package'
].
count
(
'='
)
>
1
:
module
.
fail_json
(
msg
=
'invalid package spec'
)
if
p
[
'state'
]
==
'latest'
:
if
'='
in
p
[
'package'
]:
module
.
fail_json
(
msg
=
'version number inconsistent with state=latest'
)
module
.
fail_json
(
msg
=
'version number inconsistent with state=latest'
)
install
(
module
,
p
[
'package'
],
cache
,
upgrade
=
True
,
default_release
=
p
[
'default_release'
],
install_recommends
=
install_recommends
,
...
...
@@ -161,8 +161,8 @@ def main():
install
(
module
,
p
[
'package'
],
cache
,
default_release
=
p
[
'default_release'
],
install_recommends
=
install_recommends
,
force
=
force_yes
)
elif
p
[
'state'
]
==
'removed'
:
remove
(
module
,
p
[
'package'
],
cache
,
purge
=
module
s
.
boolean
(
p
[
'purge'
]))
remove
(
module
,
p
[
'package'
],
cache
,
purge
=
module
.
boolean
(
p
[
'purge'
]))
#
this
is
magic
,
see
lib
/
ansible
/
module_common
.
py
#<<
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