@ -174,6 +174,9 @@ def build_option_parser(action):
'-p', '--init-path', dest='init_path', default="./",
'-p', '--init-path', dest='init_path', default="./",
help='The path in which the skeleton role will be created. '
help='The path in which the skeleton role will be created. '
'The default is the current working directory.')
'The default is the current working directory.')
parser.add_option(
'--offline', dest='offline', default=False, action='store_true',
help="Don't query the galaxy API when creating roles")
elif action == "install":
elif action == "install":
parser.set_usage("usage: %prog install [options] [-r FILE | role_name(s)[,version] | scm+role_repo_url[,version] | tar_file(s)]")
parser.set_usage("usage: %prog install [options] [-r FILE | role_name(s)[,version] | scm+role_repo_url[,version] | tar_file(s)]")
parser.add_option(
parser.add_option(
@ -573,7 +576,9 @@ def execute_init(args, options, parser):
init_path = get_opt(options, 'init_path', './')
init_path = get_opt(options, 'init_path', './')
api_server = get_opt(options, "api_server", "galaxy.ansible.com")
api_server = get_opt(options, "api_server", "galaxy.ansible.com")
force = get_opt(options, 'force', False)
force = get_opt(options, 'force', False)
offline = get_opt(options, 'offline', False)
if not offline:
api_config = api_get_config(api_server)
api_config = api_get_config(api_server)
if not api_config:
if not api_config:
print "The API server (%s) is not responding, please try again later." % api_server
print "The API server (%s) is not responding, please try again later." % api_server
@ -623,12 +628,12 @@ def execute_init(args, options, parser):
# datastructure in place, plus with all of the available
# datastructure in place, plus with all of the available
# tags/platforms included (but commented out) and the
# tags/platforms included (but commented out) and the
# dependencies section
# dependencies section
platforms = api_get_list(api_server, "platforms")
if not platforms:
platforms = []
platforms = []
categories = api_get_list(api_server, "categories")
if not offline:
if not categories:
platforms = api_get_list(api_server, "platforms") or []
categories = []
categories = []
if not offline:
categories = api_get_list(api_server, "categories") or []
# group the list of platforms from the api based
# group the list of platforms from the api based
# on their names, with the release field being
# on their names, with the release field being
@ -692,11 +697,6 @@ def execute_install(args, options, parser):
print "Please specify a user/role name, or a roles file, but not both"
print "Please specify a user/role name, or a roles file, but not both"
sys.exit(1)
sys.exit(1)
api_config = api_get_config(api_server)
if not api_config:
print "The API server (%s) is not responding, please try again later." % api_server
sys.exit(1)
roles_done = []
roles_done = []
if role_file:
if role_file:
f = open(role_file, 'r')
f = open(role_file, 'r')
@ -709,7 +709,7 @@ def execute_install(args, options, parser):
else:
else:
# roles were specified directly, so we'll just go out grab them
# roles were specified directly, so we'll just go out grab them
# (and their dependencies, unless the user doesn't want us to).
# (and their dependencies, unless the user doesn't want us to).
roles_left = args
roles_left = map(ansible.utils.role_spec_parse, args)
while len(roles_left) > 0:
while len(roles_left) > 0:
# query the galaxy API for the role data
# query the galaxy API for the role data
@ -730,6 +730,11 @@ def execute_install(args, options, parser):
tmp_file = fetch_role(role_src, None, None, options)
tmp_file = fetch_role(role_src, None, None, options)
else:
else:
# installing from galaxy
# installing from galaxy
api_config = api_get_config(api_server)
if not api_config:
print "The API server (%s) is not responding, please try again later." % api_server
sys.exit(1)
role_data = api_lookup_role_by_name(api_server, role_src)
role_data = api_lookup_role_by_name(api_server, role_src)
if not role_data:
if not role_data:
print "Sorry, %s was not found on %s." % (role_src, api_server)
print "Sorry, %s was not found on %s." % (role_src, api_server)