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
514fa73f
Commit
514fa73f
authored
Aug 27, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
galaxy fixes
parent
c6e62b6b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
7 deletions
+87
-7
lib/ansible/cli/galaxy.py
+4
-3
lib/ansible/galaxy/role.py
+46
-0
lib/ansible/inventory/__init__.py
+0
-4
lib/ansible/playbook/role/requirement.py
+33
-0
test/integration/galaxy_roles.yml
+4
-0
No files found.
lib/ansible/cli/galaxy.py
View file @
514fa73f
...
...
@@ -38,7 +38,6 @@ from ansible.galaxy.api import GalaxyAPI
from
ansible.galaxy.role
import
GalaxyRole
from
ansible.playbook.role.requirement
import
RoleRequirement
class
GalaxyCLI
(
CLI
):
VALID_ACTIONS
=
(
"init"
,
"info"
,
"install"
,
"list"
,
"remove"
,
"search"
)
...
...
@@ -360,6 +359,7 @@ class GalaxyCLI(CLI):
if
role_file
:
self
.
display
.
debug
(
'Getting roles from
%
s'
%
role_file
)
try
:
self
.
display
.
debug
(
'Processing role file:
%
s'
%
role_file
)
f
=
open
(
role_file
,
'r'
)
if
role_file
.
endswith
(
'.yaml'
)
or
role_file
.
endswith
(
'.yml'
):
try
:
...
...
@@ -389,13 +389,14 @@ class GalaxyCLI(CLI):
role
=
roles_left
.
pop
(
0
)
role_path
=
role
.
path
self
.
display
.
debug
(
'Installing role
%
s'
%
role_path
)
if
role_path
:
self
.
options
.
roles_path
=
role_path
else
:
self
.
options
.
roles_path
=
roles_path
self
.
display
.
debug
(
'Installing role
%
s from
%
s'
%
(
role
.
name
,
self
.
options
.
roles_path
))
tmp_file
=
None
installed
=
False
if
role
.
src
and
os
.
path
.
isfile
(
role
.
src
):
...
...
@@ -404,7 +405,7 @@ class GalaxyCLI(CLI):
else
:
if
role
.
scm
:
# create tar file from scm url
tmp_file
=
scm_archive_role
(
role
.
scm
,
role
.
src
,
role
.
version
,
role
.
name
)
tmp_file
=
GalaxyRole
.
scm_archive_role
(
role
.
scm
,
role
.
src
,
role
.
version
,
role
.
name
)
if
role
.
src
:
if
'://'
not
in
role
.
src
:
role_data
=
self
.
api
.
lookup_role_by_name
(
role
.
src
)
...
...
lib/ansible/galaxy/role.py
View file @
514fa73f
...
...
@@ -312,3 +312,49 @@ class GalaxyRole(object):
trailing_path
=
trailing_path
.
split
(
','
)[
0
]
return
trailing_path
@staticmethod
def
scm_archive_role
(
scm
,
role_url
,
role_version
,
role_name
):
if
scm
not
in
[
'hg'
,
'git'
]:
self
.
display
.
display
(
"- scm
%
s is not currently supported"
%
scm
)
return
False
tempdir
=
tempfile
.
mkdtemp
()
clone_cmd
=
[
scm
,
'clone'
,
role_url
,
role_name
]
with
open
(
'/dev/null'
,
'w'
)
as
devnull
:
try
:
self
.
display
.
display
(
"- executing:
%
s"
%
" "
.
join
(
clone_cmd
))
popen
=
subprocess
.
Popen
(
clone_cmd
,
cwd
=
tempdir
,
stdout
=
devnull
,
stderr
=
devnull
)
except
:
raise
AnsibleError
(
"error executing:
%
s"
%
" "
.
join
(
clone_cmd
))
rc
=
popen
.
wait
()
if
rc
!=
0
:
self
.
display
.
display
(
"- command
%
s failed"
%
' '
.
join
(
clone_cmd
))
self
.
display
.
display
(
" in directory
%
s"
%
tempdir
)
return
False
temp_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
suffix
=
'.tar'
)
if
scm
==
'hg'
:
archive_cmd
=
[
'hg'
,
'archive'
,
'--prefix'
,
"
%
s/"
%
role_name
]
if
role_version
:
archive_cmd
.
extend
([
'-r'
,
role_version
])
archive_cmd
.
append
(
temp_file
.
name
)
if
scm
==
'git'
:
archive_cmd
=
[
'git'
,
'archive'
,
'--prefix=
%
s/'
%
role_name
,
'--output=
%
s'
%
temp_file
.
name
]
if
role_version
:
archive_cmd
.
append
(
role_version
)
else
:
archive_cmd
.
append
(
'HEAD'
)
with
open
(
'/dev/null'
,
'w'
)
as
devnull
:
self
.
display
.
display
(
"- executing:
%
s"
%
" "
.
join
(
archive_cmd
))
popen
=
subprocess
.
Popen
(
archive_cmd
,
cwd
=
os
.
path
.
join
(
tempdir
,
role_name
),
stderr
=
devnull
,
stdout
=
devnull
)
rc
=
popen
.
wait
()
if
rc
!=
0
:
self
.
display
.
display
(
"- command
%
s failed"
%
' '
.
join
(
archive_cmd
))
self
.
display
.
display
(
" in directory
%
s"
%
tempdir
)
return
False
shutil
.
rmtree
(
tempdir
,
ignore_errors
=
True
)
return
temp_file
.
name
lib/ansible/inventory/__init__.py
View file @
514fa73f
...
...
@@ -45,10 +45,6 @@ class Inventory(object):
Host inventory for ansible.
"""
#__slots__ = [ 'host_list', 'groups', '_restriction', '_subset',
# 'parser', '_vars_per_host', '_vars_per_group', '_hosts_cache', '_groups_list',
# '_pattern_cache', '_vault_password', '_vars_plugins', '_playbook_basedir']
def
__init__
(
self
,
loader
,
variable_manager
,
host_list
=
C
.
DEFAULT_HOST_LIST
):
# the host file file, or script path, or list of hosts
...
...
lib/ansible/playbook/role/requirement.py
View file @
514fa73f
...
...
@@ -164,3 +164,36 @@ class RoleRequirement(RoleDefinition):
return
dict
(
scm
=
scm
,
src
=
role_url
,
version
=
role_version
,
role_name
=
role_name
)
def
role_yaml_parse
(
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"
]
=
repo_url_to_role_name
(
role
[
"src"
])
if
'version'
not
in
role
:
role
[
'version'
]
=
''
if
'scm'
not
in
role
:
role
[
'scm'
]
=
None
return
role
test/integration/galaxy_roles.yml
View file @
514fa73f
# change these to some ansible owned test roles
-
src
:
briancoca.oracle_java7
name
:
oracle_java7
-
src
:
git+http://bitbucket.org/willthames/git-ansible-galaxy
version
:
v1.4
...
...
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