Ansible galaxy role download should not have to perform aditionnal check against tar archive file extension #56616. (#56617)
Ansible galaxy role download checked for `.tar.gz`, but `tarfile.is_tarfile(...)` can identify and open any valid tarfile. This change uses transparent stream compression to make `.tar.gz` and `.tar.bz2` formats valid with python 2.6.x/2.7.x (as well as `.tar.xz` with python 3.x).
This commit is contained in:
parent
6131de29d4
commit
1a5fd720a4
3 changed files with 12 additions and 7 deletions
|
@ -120,7 +120,15 @@ Use the following example as a guide for specifying roles in *requirements.yml*:
|
||||||
|
|
||||||
# from a webserver, where the role is packaged in a tar.gz
|
# from a webserver, where the role is packaged in a tar.gz
|
||||||
- src: https://some.webserver.example.com/files/master.tar.gz
|
- src: https://some.webserver.example.com/files/master.tar.gz
|
||||||
name: http-role
|
name: http-role-gz
|
||||||
|
|
||||||
|
# from a webserver, where the role is packaged in a tar.bz2
|
||||||
|
- src: https://some.webserver.example.com/files/master.tar.bz2
|
||||||
|
name: http-role-bz2
|
||||||
|
|
||||||
|
# from a webserver, where the role is packaged in a tar.xz (Python 3.x only)
|
||||||
|
- src: https://some.webserver.example.com/files/master.tar.xz
|
||||||
|
name: http-role-xz
|
||||||
|
|
||||||
# from Bitbucket
|
# from Bitbucket
|
||||||
- src: git+https://bitbucket.org/willthames/git-ansible-galaxy
|
- src: git+https://bitbucket.org/willthames/git-ansible-galaxy
|
||||||
|
|
|
@ -319,7 +319,7 @@ class GalaxyCLI(CLI):
|
||||||
def execute_install(self):
|
def execute_install(self):
|
||||||
"""
|
"""
|
||||||
uses the args list of roles to be installed, unless -f was specified. The list of roles
|
uses the args list of roles to be installed, unless -f was specified. The list of roles
|
||||||
can be a name (which will be downloaded via the galaxy API and github), or it can be a local .tar.gz file.
|
can be a name (which will be downloaded via the galaxy API and github), or it can be a local tar archive file.
|
||||||
"""
|
"""
|
||||||
role_file = context.CLIARGS['role_file']
|
role_file = context.CLIARGS['role_file']
|
||||||
|
|
||||||
|
|
|
@ -256,10 +256,7 @@ class GalaxyRole(object):
|
||||||
display.debug("installing from %s" % tmp_file)
|
display.debug("installing from %s" % tmp_file)
|
||||||
|
|
||||||
if not tarfile.is_tarfile(tmp_file):
|
if not tarfile.is_tarfile(tmp_file):
|
||||||
raise AnsibleError("the file downloaded was not a tar.gz")
|
raise AnsibleError("the downloaded file does not appear to be a valid tar archive.")
|
||||||
else:
|
|
||||||
if tmp_file.endswith('.gz'):
|
|
||||||
role_tar_file = tarfile.open(tmp_file, "r:gz")
|
|
||||||
else:
|
else:
|
||||||
role_tar_file = tarfile.open(tmp_file, "r")
|
role_tar_file = tarfile.open(tmp_file, "r")
|
||||||
# verify the role's meta file
|
# verify the role's meta file
|
||||||
|
|
Loading…
Reference in a new issue