Add special token to insert the minion id into the default_include path

This commit is contained in:
C. R. Oldham 2017-03-09 15:31:16 -07:00
parent 801ff28053
commit e4aef54c73
3 changed files with 15 additions and 3 deletions

View file

@ -2110,6 +2110,17 @@ file.
files are prefixed with an underscore. A common example of this is the
``_schedule.conf`` file.
.. note::
The configuration system supports adding the special token ``{id}`` to this
option. At startup ``{id}`` will be replaced by the minion's ID, and the
default_include directory will be set here. For example, if the minion's
ID is 'webserver' and ``default_include`` is set to ``minion.d/{id}/*.conf``
then the default_include directive will be set to ``minion.d/webserver/*.conf``.
This is for situations when there are multiple minions or proxy minions
running on a single machine that need different configurations, specifically for
their schedulers.
``include``
-----------

View file

@ -1930,6 +1930,7 @@ def minion_config(path,
overrides = load_config(path, env_var, DEFAULT_MINION_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,
@ -3162,6 +3163,9 @@ def apply_minion_config(overrides=None,
newdirectory = os.path.join(opts[directory], opts['id'])
opts[directory] = newdirectory
if 'default_include' in overrides and '{id}' in overrides['default_include']:
opts['default_include'] = overrides['default_include'].replace('{id}', opts['id'])
# pidfile can be in the list of append_minionid_config_dirs, but pidfile
# is the actual path with the filename, not a directory.
if 'pidfile' in opts.get('append_minionid_config_dirs', []):

View file

@ -443,9 +443,6 @@ class Schedule(object):
config_dir,
os.path.dirname(self.opts.get('default_include',
salt.config.DEFAULT_MINION_OPTS['default_include'])))
if salt.utils.is_proxy():
# each proxy will have a separate _schedule.conf file
minion_d_dir = os.path.join(minion_d_dir, self.opts['proxyid'])
if not os.path.isdir(minion_d_dir):
os.makedirs(minion_d_dir)