From 7eff90d61d7a9424427a91ec8156f6418480a5a8 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Thu, 3 Nov 2016 15:33:28 -0600 Subject: [PATCH] Make api opts respect correct root_dir --- salt/config/__init__.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 2d6dd29c7e..ffa2eb0354 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1388,8 +1388,8 @@ CLOUD_CONFIG_DEFAULTS = { DEFAULT_API_OPTS = { # ----- Salt master settings overridden by Salt-API ---------------------> - 'pidfile': '/var/run/salt-api.pid', - 'logfile': '/var/log/salt/api', + 'api_pidfile': os.path.join(salt.syspaths.PIDFILE_DIR, 'salt-api.pid'), + 'api_logfile': os.path.join(salt.syspaths.LOGS_DIR, 'api'), 'rest_timeout': 300, # <---- Salt master settings overridden by Salt-API ---------------------- } @@ -3284,12 +3284,23 @@ def api_config(path): Read in the salt master config file and add additional configs that need to be stubbed out for salt-api ''' - # Let's grab a copy of salt's master default opts - defaults = DEFAULT_MASTER_OPTS + # Let's grab a copy of salt's master opts + opts = client_config(path, defaults=DEFAULT_MASTER_OPTS) # Let's override them with salt-api's required defaults - defaults.update(DEFAULT_API_OPTS) - - return client_config(path, defaults=defaults) + api_opts = { + 'log_file': opts.get( + 'api_logfile', os.path.join( + opts['root_dir'], DEFAULT_API_OPTS['api_logfile'].lstrip('/') + ) + ), + 'pidfile': opts.get( + 'api_pidfile', os.path.join( + opts['root_dir'], DEFAULT_API_OPTS['api_pidfile'].lstrip('/') + ) + ), + } + opts.update(api_opts) + return opts def spm_config(path):