summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Tanner <tanner.jc@gmail.com>2013-12-18 22:40:58 -0500
committerJames Tanner <tanner.jc@gmail.com>2013-12-20 13:19:00 -0500
commit1057505768ac496336ef87d6fd0055aa8732dd6e (patch)
tree9ca94c4f54627bc5806144608183b36b5927ccb8
parent42d9936b8b21febd9e0fea8ebe32f5451e2523d6 (diff)
downloadansible-1057505768ac496336ef87d6fd0055aa8732dd6e.tar.gz
Fixes #5341 Use constants.py to set the roles directory
-rwxr-xr-xbin/ansible-galaxy10
-rw-r--r--lib/ansible/constants.py2
2 files changed, 7 insertions, 5 deletions
diff --git a/bin/ansible-galaxy b/bin/ansible-galaxy
index 7593181c04..f981de1792 100755
--- a/bin/ansible-galaxy
+++ b/bin/ansible-galaxy
@@ -37,6 +37,8 @@ from distutils.version import LooseVersion
from jinja2 import Environment
from optparse import OptionParser
+import ansible.constants as C
+
default_meta_template = """---
galaxy_info:
author: {{ author }}
@@ -137,7 +139,7 @@ def build_option_parser(action):
# options that apply to more than one action
if action != "init":
parser.add_option(
- '-p', '--roles-path', dest='roles_path', default="/etc/ansible/roles",
+ '-p', '--roles-path', dest='roles_path', default=C.DEFAULT_ROLES_PATH,
help='The path to the directory containing your roles.'
'The default is the roles_path configured in your '
'ansible.cfg file (/etc/ansible/roles if not configured)')
@@ -272,7 +274,7 @@ def get_role_path(role_name, options):
Returns the role path based on the roles_path option
and the role name.
"""
- roles_path = get_opt(options,'roles_path','/etc/ansible/roles')
+ roles_path = get_opt(options,'roles_path')
return os.path.join(roles_path, role_name)
def get_role_metadata(role_name, options):
@@ -280,8 +282,8 @@ def get_role_metadata(role_name, options):
Returns the metadata as YAML, if the file 'meta/main.yml'
exists in the specified role_path
"""
+ role_path = os.path.join(get_role_path(role_name, options), 'meta/main.yml')
try:
- role_path = os.path.join(get_role_path(role_name, options), 'meta/main.yml')
if os.path.isfile(role_path):
f = open(role_path, 'r')
meta_data = yaml.safe_load(f)
@@ -689,7 +691,7 @@ def execute_list(args, options):
print "The role %s was not found" % role_name
else:
# show all valid roles in the roles_path directory
- roles_path = get_opt(options, 'roles_path', '/etc/ansible/roles')
+ roles_path = get_opt(options, 'roles_path')
if not os.path.exists(roles_path):
print "The path %s does not exist. Please specify a valid path with --roles-path" % roles_path
sys.exit(1)
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index 460ae74036..66ad32f955 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -100,7 +100,7 @@ DEFAULTS='defaults'
# configurable things
DEFAULT_HOST_LIST = shell_expand_path(get_config(p, DEFAULTS, 'hostfile', 'ANSIBLE_HOSTS', '/etc/ansible/hosts'))
DEFAULT_MODULE_PATH = get_config(p, DEFAULTS, 'library', 'ANSIBLE_LIBRARY', DIST_MODULE_PATH)
-DEFAULT_ROLES_PATH = get_config(p, DEFAULTS, 'roles_path', 'ANSIBLE_ROLES_PATH', None)
+DEFAULT_ROLES_PATH = get_config(p, DEFAULTS, 'roles_path', 'ANSIBLE_ROLES_PATH', '/etc/ansible/roles')
DEFAULT_REMOTE_TMP = shell_expand_path(get_config(p, DEFAULTS, 'remote_tmp', 'ANSIBLE_REMOTE_TEMP', '$HOME/.ansible/tmp'))
DEFAULT_MODULE_NAME = get_config(p, DEFAULTS, 'module_name', None, 'command')
DEFAULT_PATTERN = get_config(p, DEFAULTS, 'pattern', None, '*')