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
23990b94
Commit
23990b94
authored
Mar 17, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6529 from sivel/apt-repository-no-pycurl
Remove dependency on pycurl in apt_repository
parents
94e3350b
7af8a33d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
39 deletions
+11
-39
library/packaging/apt_repository
+11
-39
No files found.
library/packaging/apt_repository
View file @
23990b94
...
@@ -31,7 +31,6 @@ notes:
...
@@ -31,7 +31,6 @@ notes:
- This module works on Debian and Ubuntu and requires C(python-apt).
- This module works on Debian and Ubuntu and requires C(python-apt).
- This module supports Debian Squeeze (version 6) as well as its successors.
- This module supports Debian Squeeze (version 6) as well as its successors.
- This module treats Debian and Ubuntu distributions separately. So PPA could be installed only on Ubuntu machines.
- This module treats Debian and Ubuntu distributions separately. So PPA could be installed only on Ubuntu machines.
Adding PPA repositories requires C(python-pycurl).
options:
options:
repo:
repo:
required: true
required: true
...
@@ -52,7 +51,7 @@ options:
...
@@ -52,7 +51,7 @@ options:
choices: [ "yes", "no" ]
choices: [ "yes", "no" ]
author: Alexander Saltanov
author: Alexander Saltanov
version_added: "0.7"
version_added: "0.7"
requirements: [ python-apt
, python-pycurl
]
requirements: [ python-apt ]
'''
'''
EXAMPLES
=
'''
EXAMPLES
=
'''
...
@@ -71,10 +70,6 @@ apt_repository: repo='ppa:nginx/stable'
...
@@ -71,10 +70,6 @@ apt_repository: repo='ppa:nginx/stable'
'''
'''
import
glob
import
glob
try
:
import
json
except
ImportError
:
import
simplejson
as
json
import
os
import
os
import
re
import
re
import
tempfile
import
tempfile
...
@@ -88,23 +83,10 @@ try:
...
@@ -88,23 +83,10 @@ try:
except
ImportError
:
except
ImportError
:
HAVE_PYTHON_APT
=
False
HAVE_PYTHON_APT
=
False
try
:
import
pycurl
HAVE_PYCURL
=
True
except
ImportError
:
HAVE_PYCURL
=
False
VALID_SOURCE_TYPES
=
(
'deb'
,
'deb-src'
)
VALID_SOURCE_TYPES
=
(
'deb'
,
'deb-src'
)
class
CurlCallback
:
def
__init__
(
self
):
self
.
contents
=
''
def
body_callback
(
self
,
buf
):
self
.
contents
=
self
.
contents
+
buf
class
InvalidSource
(
Exception
):
class
InvalidSource
(
Exception
):
pass
pass
...
@@ -291,31 +273,19 @@ class SourcesList(object):
...
@@ -291,31 +273,19 @@ class SourcesList(object):
class
UbuntuSourcesList
(
SourcesList
):
class
UbuntuSourcesList
(
SourcesList
):
LP_API
=
'https://launchpad.net/api/1.0/~
%
s/+archive/
%
s'
LP_API
=
'https://launchpad.net/api/1.0/~
%
s/+archive/
%
s'
def
__init__
(
self
,
add_ppa_signing_keys_callback
=
None
):
def
__init__
(
self
,
module
,
add_ppa_signing_keys_callback
=
None
):
self
.
module
=
module
self
.
add_ppa_signing_keys_callback
=
add_ppa_signing_keys_callback
self
.
add_ppa_signing_keys_callback
=
add_ppa_signing_keys_callback
super
(
UbuntuSourcesList
,
self
)
.
__init__
()
super
(
UbuntuSourcesList
,
self
)
.
__init__
()
def
_get_ppa_info
(
self
,
owner_name
,
ppa_name
):
def
_get_ppa_info
(
self
,
owner_name
,
ppa_name
):
# we can not use urllib2 here as it does not do cert verification
if
not
HAVE_PYCURL
:
module
.
fail_json
(
msg
=
'Could not import python modules: pycurl. Please install python-pycurl package.'
)
lp_api
=
self
.
LP_API
%
(
owner_name
,
ppa_name
)
lp_api
=
self
.
LP_API
%
(
owner_name
,
ppa_name
)
return
self
.
_get_ppa_info_curl
(
lp_api
)
headers
=
dict
(
Accept
=
'application/json'
)
def
_get_ppa_info_curl
(
self
,
lp_api
):
response
,
info
=
fetch_url
(
self
.
module
,
lp_api
,
headers
=
headers
)
callback
=
CurlCallback
()
return
json
.
load
(
response
)
curl
=
pycurl
.
Curl
()
curl
.
setopt
(
pycurl
.
SSL_VERIFYPEER
,
1
)
curl
.
setopt
(
pycurl
.
SSL_VERIFYHOST
,
2
)
curl
.
setopt
(
pycurl
.
WRITEFUNCTION
,
callback
.
body_callback
)
curl
.
setopt
(
pycurl
.
URL
,
str
(
lp_api
))
curl
.
setopt
(
pycurl
.
HTTPHEADER
,
[
"Accept: application/json"
])
curl
.
perform
()
curl
.
close
()
lp_page
=
callback
.
contents
return
json
.
loads
(
lp_page
)
def
_expand_ppa
(
self
,
path
):
def
_expand_ppa
(
self
,
path
):
ppa
=
path
.
split
(
':'
)[
1
]
ppa
=
path
.
split
(
':'
)[
1
]
...
@@ -380,7 +350,8 @@ def main():
...
@@ -380,7 +350,8 @@ def main():
sourceslist
=
None
sourceslist
=
None
if
isinstance
(
distro
,
aptsources
.
distro
.
UbuntuDistribution
):
if
isinstance
(
distro
,
aptsources
.
distro
.
UbuntuDistribution
):
sourceslist
=
UbuntuSourcesList
(
add_ppa_signing_keys_callback
=
get_add_ppa_signing_key_callback
(
module
))
sourceslist
=
UbuntuSourcesList
(
module
,
add_ppa_signing_keys_callback
=
get_add_ppa_signing_key_callback
(
module
))
elif
isinstance
(
distro
,
aptsources
.
distro
.
DebianDistribution
)
or
\
elif
isinstance
(
distro
,
aptsources
.
distro
.
DebianDistribution
)
or
\
isinstance
(
distro
,
aptsources
.
distro
.
Distribution
):
isinstance
(
distro
,
aptsources
.
distro
.
Distribution
):
sourceslist
=
SourcesList
()
sourceslist
=
SourcesList
()
...
@@ -413,5 +384,6 @@ def main():
...
@@ -413,5 +384,6 @@ def main():
# import module snippets
# import module snippets
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.urls
import
*
main
()
main
()
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