... | ... |
@@ -318,7 +318,8 @@ class GalaxyCLI(CLI): |
318 | 318 |
# roles listed in a file, one per line |
319 | 319 |
for rline in f.readlines(): |
320 | 320 |
self.display.debug('found role %s in text file' % str(rline)) |
321 |
- roles_left.append(GalaxyRole(self.galaxy, **RoleRequirement.role_yaml_parse(rline))) |
|
321 |
+ role = RoleRequirement.role_yaml_parse(rline) |
|
322 |
+ roles_left.append(GalaxyRole(self.galaxy, **role)) |
|
322 | 323 |
f.close() |
323 | 324 |
except (IOError, OSError) as e: |
324 | 325 |
self.display.error('Unable to open %s: %s' % (role_file, str(e))) |
... | ... |
@@ -113,11 +113,31 @@ class RoleRequirement(RoleDefinition): |
113 | 113 |
@staticmethod |
114 | 114 |
def role_yaml_parse(role): |
115 | 115 |
|
116 |
+ if isinstance(role, string_types): |
|
117 |
+ name = None |
|
118 |
+ scm = None |
|
119 |
+ src = None |
|
120 |
+ version = None |
|
121 |
+ if ',' in role: |
|
122 |
+ if role.count(',') == 1: |
|
123 |
+ (src, version) = role.strip().split(',', 1) |
|
124 |
+ elif role.count(',') == 2: |
|
125 |
+ (src, version, name) = role.strip().split(',', 2) |
|
126 |
+ else: |
|
127 |
+ raise AnsibleError("Invalid role line (%s). Proper format is 'role_name[,version[,name]]'" % role) |
|
128 |
+ else: |
|
129 |
+ src = role |
|
130 |
+ |
|
131 |
+ if name is None: |
|
132 |
+ name = RoleRequirement.repo_url_to_role_name(src) |
|
133 |
+ if '+' in src: |
|
134 |
+ (scm, src) = src.split('+', 1) |
|
135 |
+ |
|
136 |
+ return dict(name=name, src=src, scm=scm, version=version) |
|
137 |
+ |
|
116 | 138 |
if 'role' in role: |
117 | 139 |
# Old style: {role: "galaxy.role,version,name", other_vars: "here" } |
118 | 140 |
role = RoleRequirement.role_spec_parse(role['role']) |
119 |
- #if 'name' in role: |
|
120 |
- # del role['name'] |
|
121 | 141 |
else: |
122 | 142 |
role = role.copy() |
123 | 143 |
# New style: { src: 'galaxy.role,version,name', other_vars: "here" } |
... | ... |
@@ -157,7 +177,7 @@ class RoleRequirement(RoleDefinition): |
157 | 157 |
raise AnsibleError("error executing: %s" % " ".join(clone_cmd)) |
158 | 158 |
rc = popen.wait() |
159 | 159 |
if rc != 0: |
160 |
- raise AnsibleError ("- command %s failed in directory %s" % (' '.join(clone_cmd), tempdir)) |
|
160 |
+ raise AnsibleError ("- command %s failed in directory %s (rc=%s)" % (' '.join(clone_cmd), tempdir, rc)) |
|
161 | 161 |
|
162 | 162 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar') |
163 | 163 |
if scm == 'hg': |
... | ... |
@@ -177,7 +197,7 @@ class RoleRequirement(RoleDefinition): |
177 | 177 |
stderr=devnull, stdout=devnull) |
178 | 178 |
rc = popen.wait() |
179 | 179 |
if rc != 0: |
180 |
- raise AnsibleError("- command %s failed in directory %s" % (' '.join(archive_cmd), tempdir)) |
|
180 |
+ raise AnsibleError("- command %s failed in directory %s (rc=%s)" % (' '.join(archive_cmd), tempdir, rc)) |
|
181 | 181 |
|
182 | 182 |
shutil.rmtree(tempdir, ignore_errors=True) |
183 | 183 |
return temp_file.name |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-git+http://bitbucket.org/willthames/git-ansible-galaxy,v1.4 |
|
2 |
-hg+http://bitbucket.org/willthames/hg-ansible-galaxy |
|
1 |
+git+https://bitbucket.org/willthames/git-ansible-galaxy,v1.4 |
|
2 |
+hg+https://bitbucket.org/willthames/hg-ansible-galaxy |
|
3 | 3 |
https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role |
4 | 4 |
git+git@github.com:geerlingguy/ansible-role-php.git |