summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Thames <will@thames.id.au>2014-08-19 08:06:46 +0200
committerMichael DeHaan <michael@ansible.com>2014-08-21 23:15:23 +0200
commit31540246dd1d05379ad03437656759479590c06d (patch)
tree3ee9b5d43069af14ac85264995618fa41a38e999
parentAllow installation of roles from yaml roles file (diff)
downloadansible-31540246dd1d05379ad03437656759479590c06d.tar.xz
ansible-31540246dd1d05379ad03437656759479590c06d.zip
Handle older git archive commands
Older git archive commands create tar archives even with a tar.gz extension. So change it to always create tar archives and have the install_role method cope. Removed ssh roles from the test case as they don't work unless you can connect to bitbucket via ssh and have your key there. Corrected a minor typo in error messages
-rwxr-xr-xbin/ansible-galaxy9
-rw-r--r--test/integration/galaxy_roles.yml2
-rw-r--r--test/integration/galaxy_rolesfile2
3 files changed, 8 insertions, 5 deletions
diff --git a/bin/ansible-galaxy b/bin/ansible-galaxy
index 3c624693b3..79594bad97 100755
--- a/bin/ansible-galaxy
+++ b/bin/ansible-galaxy
@@ -343,10 +343,10 @@ def scm_archive_role(scm, role_url, role_version, role_name):
rc = popen.wait()
if rc != 0:
print "Command %s failed" % ' '.join(clone_cmd)
- print "in directory %s" % temp_dir
+ print "in directory %s" % tempdir
return False
- temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar.gz')
+ temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar')
if scm == 'hg':
archive_cmd = ['hg', 'archive', '--prefix', "%s/" % role_name]
if role_version:
@@ -491,7 +491,10 @@ def install_role(role_name, role_version, role_filename, options):
print "Error: the file downloaded was not a tar.gz"
return False
else:
- role_tar_file = tarfile.open(role_filename, "r:gz")
+ if role_filename.endswith('.gz'):
+ role_tar_file = tarfile.open(role_filename, "r:gz")
+ else:
+ role_tar_file = tarfile.open(role_filename, "r")
# verify the role's meta file
meta_file = None
members = role_tar_file.getmembers()
diff --git a/test/integration/galaxy_roles.yml b/test/integration/galaxy_roles.yml
index f354f5985f..cd61006840 100644
--- a/test/integration/galaxy_roles.yml
+++ b/test/integration/galaxy_roles.yml
@@ -1,7 +1,7 @@
- src: git+http://bitbucket.org/willthames/git-ansible-galaxy
version: v1.4
-- src: ssh://hg@bitbucket.org/willthames/hg-ansible-galaxy
+- src: http://bitbucket.org/willthames/hg-ansible-galaxy
scm: hg
- src: https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz
diff --git a/test/integration/galaxy_rolesfile b/test/integration/galaxy_rolesfile
index 01aa27a52a..a1374925ba 100644
--- a/test/integration/galaxy_rolesfile
+++ b/test/integration/galaxy_rolesfile
@@ -1,3 +1,3 @@
git+http://bitbucket.org/willthames/git-ansible-galaxy,v1.4
-hg+ssh://hg@bitbucket.org/willthames/hg-ansible-galaxy
+hg+http://bitbucket.org/willthames/hg-ansible-galaxy
https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role