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
e4ad97b9
Commit
e4ad97b9
authored
Mar 12, 2014
by
Andy Trevorah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reworked apt-repository auto-install to be like yum
parent
12802698
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
15 deletions
+34
-15
library/packaging/apt_repository
+34
-15
No files found.
library/packaging/apt_repository
View file @
e4ad97b9
...
...
@@ -95,6 +95,26 @@ except ImportError:
VALID_SOURCE_TYPES
=
(
'deb'
,
'deb-src'
)
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
))
if
rc
==
0
:
global
apt
,
apt_pkg
import
apt
import
apt_pkg
def
install_python_pycurl
(
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-pycurl -y -q'
%
(
apt_get_path
,
apt_get_path
))
if
rc
==
0
:
global
pycurl
import
pycurl
class
CurlCallback
:
def
__init__
(
self
):
...
...
@@ -361,25 +381,24 @@ def main():
repo
=
dict
(
required
=
True
),
state
=
dict
(
choices
=
[
'present'
,
'absent'
],
default
=
'present'
),
update_cache
=
dict
(
aliases
=
[
'update-cache'
],
type
=
'bool'
,
default
=
'yes'
),
# this should not be needed, but exists as a failsafe
install_python_apt
=
dict
(
required
=
False
,
default
=
"yes"
,
type
=
'bool'
),
# this should not be needed, but exists as a failsafe
install_python_pycurl
=
dict
(
required
=
False
,
default
=
"yes"
,
type
=
'bool'
),
),
supports_check_mode
=
True
,
)
if
not
HAVE_PYTHON_APT
:
try
:
module
.
run_command
(
'apt-get update && apt-get install python-apt -y -q'
)
global
apt
,
apt_pkg
import
apt
import
apt_pkg
except
:
module
.
fail_json
(
msg
=
'Could not import python modules: apt, apt_pkg. Please install python-apt package.'
)
if
not
HAVE_PYCURL
:
module
.
fail_json
(
msg
=
'Could not import python modules: pycurl. Please install python-pycurl package.'
)
repo
=
module
.
params
[
'repo'
]
state
=
module
.
params
[
'state'
]
update_cache
=
module
.
params
[
'update_cache'
]
params
=
module
.
params
if
params
[
'install_python_apt'
]
and
not
HAVE_PYTHON_APT
and
not
module
.
check_mode
:
install_python_apt
(
module
)
if
params
[
'install_python_pycurl'
]
and
not
HAVE_PYCURL
and
not
module
.
check_mode
:
install_python_pycurl
(
module
)
repo
=
params
[
'repo'
]
state
=
params
[
'state'
]
update_cache
=
params
[
'update_cache'
]
sourceslist
=
None
if
isinstance
(
distro
,
aptsources
.
distro
.
UbuntuDistribution
):
...
...
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