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
9943c508
Commit
9943c508
authored
May 06, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure distro variable is set if python-apt is installed
Fixes #7295
parent
ce15813e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
library/packaging/apt_repository
+16
-8
No files found.
library/packaging/apt_repository
View file @
9943c508
...
...
@@ -83,10 +83,11 @@ import tempfile
try
:
import
apt
import
apt_pkg
import
aptsources.distro
distro
=
aptsources
.
distro
.
get_distro
()
import
aptsources.distro
as
aptsources_distro
distro
=
aptsources
_
distro
.
get_distro
()
HAVE_PYTHON_APT
=
True
except
ImportError
:
distro
=
None
HAVE_PYTHON_APT
=
False
...
...
@@ -97,11 +98,16 @@ def install_python_apt(module):
if
not
module
.
check_mode
:
apt_get_path
=
module
.
get_bin_path
(
'apt-get'
)
if
apt_get_path
:
rc
,
so
,
se
=
module
.
run_command
(
'
%
s update &&
%
s install python-apt -y -q'
%
(
apt_get_path
,
apt_get_path
))
rc
,
so
,
se
=
module
.
run_command
(
'
%
s update &&
%
s install python-apt -y -q'
%
(
apt_get_path
,
apt_get_path
)
,
use_unsafe_shell
=
True
)
if
rc
==
0
:
global
apt
,
apt_pkg
global
apt
,
apt_pkg
,
aptsources_distro
,
distro
,
HAVE_PYTHON_APT
import
apt
import
apt_pkg
import
aptsources.distro
as
aptsources_distro
distro
=
aptsources_distro
.
get_distro
()
HAVE_PYTHON_APT
=
True
else
:
module
.
fail_json
(
msg
=
"Failed to auto-install python-apt. Error was: '
%
s'"
%
se
.
strip
())
class
InvalidSource
(
Exception
):
pass
...
...
@@ -382,14 +388,16 @@ def main():
update_cache
=
module
.
params
[
'update_cache'
]
sourceslist
=
None
if
isinstance
(
distro
,
aptsources
.
distro
.
UbuntuDistribution
):
if
HAVE_PYTHON_APT
:
if
isinstance
(
distro
,
aptsources_distro
.
UbuntuDistribution
):
sourceslist
=
UbuntuSourcesList
(
module
,
add_ppa_signing_keys_callback
=
get_add_ppa_signing_key_callback
(
module
))
elif
isinstance
(
distro
,
aptsources
.
distro
.
DebianDistribution
)
or
\
isinstance
(
distro
,
aptsources
.
distro
.
Distribution
):
elif
HAVE_PYTHON_APT
and
\
isinstance
(
distro
,
aptsources
_distro
.
DebianDistribution
)
or
isinstance
(
distro
,
aptsources_
distro
.
Distribution
):
sourceslist
=
SourcesList
()
else
:
module
.
fail_json
(
msg
=
'Module apt_repository supports only Debian and Ubuntu.'
)
module
.
fail_json
(
msg
=
'Module apt_repository supports only Debian and Ubuntu. '
+
\
'You may be seeing this because python-apt is not installed, but you requested that it not be auto-installed'
)
sources_before
=
sourceslist
.
dump
()
...
...
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