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
40caa110
Commit
40caa110
authored
Nov 12, 2014
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented info action for galaxy
parent
7812c70d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
9 deletions
+63
-9
bin/ansible-galaxy
+63
-9
No files found.
bin/ansible-galaxy
View file @
40caa110
...
...
@@ -135,6 +135,7 @@ An optional section for the role authors to include contact information, or a we
#-------------------------------------------------------------------------------------
VALID_ACTIONS
=
(
"init"
,
"info"
,
"install"
,
"list"
,
"remove"
)
SKIP_INFO_KEYS
=
(
"platforms"
,
"readme_html"
,
"related"
,
"summary_fields"
,
"average_aw_composite"
,
"average_aw_score"
,
"url"
)
def
get_action
(
args
):
"""
...
...
@@ -237,6 +238,7 @@ def exit_without_ignore(options, rc=1):
print
'- you can use --ignore-errors to skip failed roles.'
sys
.
exit
(
rc
)
#-------------------------------------------------------------------------------------
# Galaxy API functions
#-------------------------------------------------------------------------------------
...
...
@@ -257,7 +259,7 @@ def api_get_config(api_server):
except
:
return
None
def
api_lookup_role_by_name
(
api_server
,
role_name
):
def
api_lookup_role_by_name
(
api_server
,
role_name
,
notify
=
True
):
"""
Uses the Galaxy API to do a lookup on the role owner/name.
"""
...
...
@@ -268,7 +270,8 @@ def api_lookup_role_by_name(api_server, role_name):
parts
=
role_name
.
split
(
"."
)
user_name
=
"."
.
join
(
parts
[
0
:
-
1
])
role_name
=
parts
[
-
1
]
print
"- downloading role '
%
s', owned by
%
s"
%
(
role_name
,
user_name
)
if
notify
:
print
"- downloading role '
%
s', owned by
%
s"
%
(
role_name
,
user_name
)
except
:
parser
.
print_help
()
print
"- invalid role name (
%
s). Specify role as format: username.rolename"
%
role_name
...
...
@@ -640,7 +643,7 @@ def execute_init(args, options, parser):
categories
=
[]
if
not
offline
:
categories
=
api_get_list
(
api_server
,
"categories"
)
or
[]
# group the list of platforms from the api based
# on their names, with the release field being
# appended to a list of versions
...
...
@@ -676,7 +679,57 @@ def execute_info(args, options, parser):
from the galaxy API.
"""
pass
if
len
(
args
)
==
0
:
# the user needs to specify a role
parser
.
print_help
()
print
"- you must specify a user/role name"
sys
.
exit
(
1
)
api_server
=
get_opt
(
options
,
"api_server"
,
"galaxy.ansible.com"
)
api_config
=
api_get_config
(
api_server
)
roles_path
=
get_opt
(
options
,
"roles_path"
)
for
role
in
args
:
role_info
=
{}
install_info
=
get_galaxy_install_info
(
role
,
options
)
if
install_info
:
if
'version'
in
install_info
:
install_info
[
'intalled_version'
]
=
install_info
[
'version'
]
install_info
.
pop
(
'version'
,
None
)
role_info
.
update
(
install_info
)
remote_data
=
api_lookup_role_by_name
(
api_server
,
role
,
False
)
if
remote_data
:
role_info
.
update
(
remote_data
)
metadata
=
get_role_metadata
(
role
,
options
)
if
metadata
:
role_info
.
update
(
metadata
)
role_spec
=
ansible
.
utils
.
role_spec_parse
(
role
)
if
role_spec
:
role_info
.
update
(
role_spec
)
if
role_info
:
print
"-
%
s:"
%
(
role
)
import
pprint
for
k
in
sorted
(
role_info
.
keys
()):
if
k
in
SKIP_INFO_KEYS
:
continue
if
isinstance
(
role_info
[
k
],
dict
):
print
"
\t
%
s: "
%
(
k
)
for
key
in
sorted
(
role_info
[
k
]
.
keys
()):
if
key
in
SKIP_INFO_KEYS
:
continue
print
"
\t\t
%
s:
%
s"
%
(
key
,
role_info
[
k
][
key
])
else
:
print
"
\t
%
s:
%
s"
%
(
k
,
role_info
[
k
])
else
:
print
"- the role
%
s was not found"
%
role
def
execute_install
(
args
,
options
,
parser
):
"""
...
...
@@ -687,23 +740,24 @@ def execute_install(args, options, parser):
"""
role_file
=
get_opt
(
options
,
"role_file"
,
None
)
api_server
=
get_opt
(
options
,
"api_server"
,
"galaxy.ansible.com"
)
no_deps
=
get_opt
(
options
,
"no_deps"
,
False
)
roles_path
=
get_opt
(
options
,
"roles_path"
)
if
len
(
args
)
==
0
and
not
role_fil
e
:
if
len
(
args
)
==
0
and
role_file
is
Non
e
:
# the user needs to specify one of either --role-file
# or specify a single user/role name
parser
.
print_help
()
print
"- you must specify a user/role name or a roles file"
sys
.
exit
()
elif
len
(
args
)
==
1
and
role_fil
e
:
elif
len
(
args
)
==
1
and
not
role_file
is
Non
e
:
# using a role file is mutually exclusive of specifying
# the role name on the command line
parser
.
print_help
()
print
"- please specify a user/role name, or a roles file, but not both"
sys
.
exit
(
1
)
api_server
=
get_opt
(
options
,
"api_server"
,
"galaxy.ansible.com"
)
no_deps
=
get_opt
(
options
,
"no_deps"
,
False
)
roles_path
=
get_opt
(
options
,
"roles_path"
)
roles_done
=
[]
if
role_file
:
f
=
open
(
role_file
,
'r'
)
...
...
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