mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add special token to insert the minion id into the default_include path
This commit is contained in:
parent
801ff28053
commit
e4aef54c73
3 changed files with 15 additions and 3 deletions
|
@ -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``
|
||||
-----------
|
||||
|
|
|
@ -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', []):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue