Process spm.d/*.conf and add prefix root dir support to SPM directories

This commit is contained in:
Pedro Algarvio 2015-09-09 16:19:52 +01:00
parent 602559f3a9
commit c16d4e4332

View File

@ -1216,10 +1216,12 @@ DEFAULT_API_OPTS = {
DEFAULT_SPM_OPTS = {
# ----- Salt master settings overridden by SPM --------------------->
'conf_file': os.path.join(salt.syspaths.CONFIG_DIR, 'spm'),
'formula_path': '/srv/spm/salt',
'pillar_path': '/srv/spm/pillar',
'reactor_path': '/srv/spm/reactor',
'spm_logfile': '/var/log/salt/spm',
'default_include': 'spm.d/*.conf',
# spm_repos_config also includes a .d/ directory
'spm_repos_config': '/etc/salt/spm.repos',
'spm_cache_dir': os.path.join(salt.syspaths.CACHE_DIR, 'spm'),
@ -2997,4 +2999,40 @@ def spm_config(path):
# Let's override them with spm's required defaults
defaults.update(DEFAULT_SPM_OPTS)
overrides = load_config(path, 'SPM_CONFIG', DEFAULT_SPM_OPTS['conf_file'])
default_include = overrides.get('default_include',
defaults['default_include'])
include = overrides.get('include', [])
overrides.update(include_config(default_include, path, verbose=False))
overrides.update(include_config(include, path, verbose=True))
defaults = apply_master_config(overrides, defaults)
defaults = apply_spm_config(overrides, defaults)
return client_config(path, env_var='SPM_CONFIG', defaults=defaults)
def apply_spm_config(overrides, defaults):
'''
Returns the spm configurations dict.
'''
opts = defaults.copy()
if overrides:
opts.update(overrides)
# Prepend root_dir to other paths
prepend_root_dirs = [
'formula_path', 'pillar_path', 'reactor_path',
'spm_cache_dir', 'spm_build_dir'
]
# These can be set to syslog, so, not actual paths on the system
for config_key in ('spm_logfile',):
log_setting = opts.get(config_key, '')
if log_setting is None:
continue
if urlparse(log_setting).scheme == '':
prepend_root_dirs.append(config_key)
prepend_root_dir(opts, prepend_root_dirs)
return opts