summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2015-10-06 01:54:48 -0400
committerJames Cammarata <jimi@sngx.net>2015-10-06 01:54:48 -0400
commit9c9897805f00d26e41991a9c14e65e97bfa8c622 (patch)
treec1dcd6e6e7a716ba0d99eb58f063f2254599e8f7
parentfb822a43052c4ca2b79896ee6f22af603f6bed5c (diff)
downloadansible-9c9897805f00d26e41991a9c14e65e97bfa8c622.tar.gz
More ansible-galaxy fixes for the old spec file format
-rw-r--r--lib/ansible/cli/galaxy.py3
-rw-r--r--lib/ansible/playbook/role/requirement.py28
-rw-r--r--test/integration/galaxy_rolesfile4
3 files changed, 28 insertions, 7 deletions
diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py
index 1ce3bb3b81..16aff1f0fd 100644
--- a/lib/ansible/cli/galaxy.py
+++ b/lib/ansible/cli/galaxy.py
@@ -318,7 +318,8 @@ class GalaxyCLI(CLI):
# roles listed in a file, one per line
for rline in f.readlines():
self.display.debug('found role %s in text file' % str(rline))
- roles_left.append(GalaxyRole(self.galaxy, **RoleRequirement.role_yaml_parse(rline)))
+ role = RoleRequirement.role_yaml_parse(rline)
+ roles_left.append(GalaxyRole(self.galaxy, **role))
f.close()
except (IOError, OSError) as e:
self.display.error('Unable to open %s: %s' % (role_file, str(e)))
diff --git a/lib/ansible/playbook/role/requirement.py b/lib/ansible/playbook/role/requirement.py
index 3facfdd2c4..1cb98a57fa 100644
--- a/lib/ansible/playbook/role/requirement.py
+++ b/lib/ansible/playbook/role/requirement.py
@@ -113,11 +113,31 @@ class RoleRequirement(RoleDefinition):
@staticmethod
def role_yaml_parse(role):
+ if isinstance(role, string_types):
+ name = None
+ scm = None
+ src = None
+ version = None
+ if ',' in role:
+ if role.count(',') == 1:
+ (src, version) = role.strip().split(',', 1)
+ elif role.count(',') == 2:
+ (src, version, name) = role.strip().split(',', 2)
+ else:
+ raise AnsibleError("Invalid role line (%s). Proper format is 'role_name[,version[,name]]'" % role)
+ else:
+ src = role
+
+ if name is None:
+ name = RoleRequirement.repo_url_to_role_name(src)
+ if '+' in src:
+ (scm, src) = src.split('+', 1)
+
+ return dict(name=name, src=src, scm=scm, version=version)
+
if 'role' in role:
# Old style: {role: "galaxy.role,version,name", other_vars: "here" }
role = RoleRequirement.role_spec_parse(role['role'])
- #if 'name' in role:
- # del role['name']
else:
role = role.copy()
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
@@ -157,7 +177,7 @@ class RoleRequirement(RoleDefinition):
raise AnsibleError("error executing: %s" % " ".join(clone_cmd))
rc = popen.wait()
if rc != 0:
- raise AnsibleError ("- command %s failed in directory %s" % (' '.join(clone_cmd), tempdir))
+ raise AnsibleError ("- command %s failed in directory %s (rc=%s)" % (' '.join(clone_cmd), tempdir, rc))
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar')
if scm == 'hg':
@@ -177,7 +197,7 @@ class RoleRequirement(RoleDefinition):
stderr=devnull, stdout=devnull)
rc = popen.wait()
if rc != 0:
- raise AnsibleError("- command %s failed in directory %s" % (' '.join(archive_cmd), tempdir))
+ raise AnsibleError("- command %s failed in directory %s (rc=%s)" % (' '.join(archive_cmd), tempdir, rc))
shutil.rmtree(tempdir, ignore_errors=True)
return temp_file.name
diff --git a/test/integration/galaxy_rolesfile b/test/integration/galaxy_rolesfile
index 31596d4914..00be59b103 100644
--- a/test/integration/galaxy_rolesfile
+++ b/test/integration/galaxy_rolesfile
@@ -1,4 +1,4 @@
-git+http://bitbucket.org/willthames/git-ansible-galaxy,v1.4
-hg+http://bitbucket.org/willthames/hg-ansible-galaxy
+git+https://bitbucket.org/willthames/git-ansible-galaxy,v1.4
+hg+https://bitbucket.org/willthames/hg-ansible-galaxy
https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role
git+git@github.com:geerlingguy/ansible-role-php.git