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
96bcf50a
Commit
96bcf50a
authored
Jul 29, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented requirements file in v2
fixes #11179
parent
71867f94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletions
+55
-1
lib/ansible/cli/galaxy.py
+37
-1
lib/ansible/galaxy/role.py
+18
-0
No files found.
lib/ansible/cli/galaxy.py
View file @
96bcf50a
...
...
@@ -323,7 +323,10 @@ class GalaxyCLI(CLI):
if
role_file
:
f
=
open
(
role_file
,
'r'
)
if
role_file
.
endswith
(
'.yaml'
)
or
role_file
.
endswith
(
'.yml'
):
roles_left
=
map
(
ansible
.
utils
.
role_yaml_parse
,
yaml
.
safe_load
(
f
))
rolesparsed
=
map
(
self
.
parse_requirements_files
,
yaml
.
safe_load
(
f
))
import
q
q
(
rolesparsed
)
roles_left
=
[
GalaxyRole
(
self
.
galaxy
,
**
r
)
for
r
in
rolesparsed
]
else
:
# roles listed in a file, one per line
for
rname
in
f
.
readlines
():
...
...
@@ -485,3 +488,36 @@ class GalaxyCLI(CLI):
version
=
"(unknown version)"
self
.
display
.
display
(
"-
%
s,
%
s"
%
(
path_file
,
version
))
return
0
def
parse_requirements_files
(
self
,
role
):
if
'role'
in
role
:
# Old style: {role: "galaxy.role,version,name", other_vars: "here" }
role_info
=
role_spec_parse
(
role
[
'role'
])
if
isinstance
(
role_info
,
dict
):
# Warning: Slight change in behaviour here. name may be being
# overloaded. Previously, name was only a parameter to the role.
# Now it is both a parameter to the role and the name that
# ansible-galaxy will install under on the local system.
if
'name'
in
role
and
'name'
in
role_info
:
del
role_info
[
'name'
]
role
.
update
(
role_info
)
else
:
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
if
'github.com'
in
role
[
"src"
]
and
'http'
in
role
[
"src"
]
and
'+'
not
in
role
[
"src"
]
and
not
role
[
"src"
]
.
endswith
(
'.tar.gz'
):
role
[
"src"
]
=
"git+"
+
role
[
"src"
]
if
'+'
in
role
[
"src"
]:
(
scm
,
src
)
=
role
[
"src"
]
.
split
(
'+'
)
role
[
"scm"
]
=
scm
role
[
"src"
]
=
src
if
'name'
not
in
role
:
role
[
"name"
]
=
GalaxyRole
.
url_to_spec
(
role
[
"src"
])
if
'version'
not
in
role
:
role
[
'version'
]
=
''
if
'scm'
not
in
role
:
role
[
'scm'
]
=
None
return
role
lib/ansible/galaxy/role.py
View file @
96bcf50a
...
...
@@ -292,3 +292,21 @@ class GalaxyRole(object):
}
"""
return
dict
(
scm
=
self
.
scm
,
src
=
self
.
src
,
version
=
self
.
version
,
name
=
self
.
name
)
@staticmethod
def
url_to_spec
(
roleurl
):
# gets the role name out of a repo like
# http://git.example.com/repos/repo.git" => "repo"
if
'://'
not
in
roleurl
and
'@'
not
in
roleurl
:
return
roleurl
trailing_path
=
roleurl
.
split
(
'/'
)[
-
1
]
if
trailing_path
.
endswith
(
'.git'
):
trailing_path
=
trailing_path
[:
-
4
]
if
trailing_path
.
endswith
(
'.tar.gz'
):
trailing_path
=
trailing_path
[:
-
7
]
if
','
in
trailing_path
:
trailing_path
=
trailing_path
.
split
(
','
)[
0
]
return
trailing_path
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