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
9c989780
Commit
9c989780
authored
Oct 06, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More ansible-galaxy fixes for the old spec file format
parent
fb822a43
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
7 deletions
+28
-7
lib/ansible/cli/galaxy.py
+2
-1
lib/ansible/playbook/role/requirement.py
+24
-4
test/integration/galaxy_rolesfile
+2
-2
No files found.
lib/ansible/cli/galaxy.py
View file @
9c989780
...
@@ -318,7 +318,8 @@ class GalaxyCLI(CLI):
...
@@ -318,7 +318,8 @@ class GalaxyCLI(CLI):
# roles listed in a file, one per line
# roles listed in a file, one per line
for
rline
in
f
.
readlines
():
for
rline
in
f
.
readlines
():
self
.
display
.
debug
(
'found role
%
s in text file'
%
str
(
rline
))
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
()
f
.
close
()
except
(
IOError
,
OSError
)
as
e
:
except
(
IOError
,
OSError
)
as
e
:
self
.
display
.
error
(
'Unable to open
%
s:
%
s'
%
(
role_file
,
str
(
e
)))
self
.
display
.
error
(
'Unable to open
%
s:
%
s'
%
(
role_file
,
str
(
e
)))
...
...
lib/ansible/playbook/role/requirement.py
View file @
9c989780
...
@@ -113,11 +113,31 @@ class RoleRequirement(RoleDefinition):
...
@@ -113,11 +113,31 @@ class RoleRequirement(RoleDefinition):
@staticmethod
@staticmethod
def
role_yaml_parse
(
role
):
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
:
if
'role'
in
role
:
# Old style: {role: "galaxy.role,version,name", other_vars: "here" }
# Old style: {role: "galaxy.role,version,name", other_vars: "here" }
role
=
RoleRequirement
.
role_spec_parse
(
role
[
'role'
])
role
=
RoleRequirement
.
role_spec_parse
(
role
[
'role'
])
#if 'name' in role:
# del role['name']
else
:
else
:
role
=
role
.
copy
()
role
=
role
.
copy
()
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
...
@@ -157,7 +177,7 @@ class RoleRequirement(RoleDefinition):
...
@@ -157,7 +177,7 @@ class RoleRequirement(RoleDefinition):
raise
AnsibleError
(
"error executing:
%
s"
%
" "
.
join
(
clone_cmd
))
raise
AnsibleError
(
"error executing:
%
s"
%
" "
.
join
(
clone_cmd
))
rc
=
popen
.
wait
()
rc
=
popen
.
wait
()
if
rc
!=
0
:
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'
)
temp_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
suffix
=
'.tar'
)
if
scm
==
'hg'
:
if
scm
==
'hg'
:
...
@@ -177,7 +197,7 @@ class RoleRequirement(RoleDefinition):
...
@@ -177,7 +197,7 @@ class RoleRequirement(RoleDefinition):
stderr
=
devnull
,
stdout
=
devnull
)
stderr
=
devnull
,
stdout
=
devnull
)
rc
=
popen
.
wait
()
rc
=
popen
.
wait
()
if
rc
!=
0
:
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
)
shutil
.
rmtree
(
tempdir
,
ignore_errors
=
True
)
return
temp_file
.
name
return
temp_file
.
name
...
...
test/integration/galaxy_rolesfile
View file @
9c989780
git+http://bitbucket.org/willthames/git-ansible-galaxy,v1.4
git+http
s
://bitbucket.org/willthames/git-ansible-galaxy,v1.4
hg+http://bitbucket.org/willthames/hg-ansible-galaxy
hg+http
s
://bitbucket.org/willthames/hg-ansible-galaxy
https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role
https://bitbucket.org/willthames/http-ansible-galaxy/get/master.tar.gz,,http-role
git+git@github.com:geerlingguy/ansible-role-php.git
git+git@github.com:geerlingguy/ansible-role-php.git
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