mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Finalizing ability to disable requisites during State runs. Adding to configuration and documentation.
This commit is contained in:
parent
1e6840d8db
commit
7221d50450
4 changed files with 30 additions and 4 deletions
|
@ -565,6 +565,15 @@
|
||||||
#
|
#
|
||||||
#state_aggregate: False
|
#state_aggregate: False
|
||||||
|
|
||||||
|
# Disable requisites during state runs by specifying a single requisite
|
||||||
|
# or a list of requisites to disable.
|
||||||
|
#
|
||||||
|
# disabled_requisites: require_in
|
||||||
|
#
|
||||||
|
# disabled_requisites:
|
||||||
|
# - require
|
||||||
|
# - require_in
|
||||||
|
|
||||||
##### File Directory Settings #####
|
##### File Directory Settings #####
|
||||||
##########################################
|
##########################################
|
||||||
# The Salt Minion can redirect all file server operations to a local directory,
|
# The Salt Minion can redirect all file server operations to a local directory,
|
||||||
|
|
|
@ -77,3 +77,9 @@ You can set this setting in your roster file like so:
|
||||||
user: root
|
user: root
|
||||||
passwd: P@ssword
|
passwd: P@ssword
|
||||||
set_path: '$PATH:/usr/local/bin/'
|
set_path: '$PATH:/usr/local/bin/'
|
||||||
|
|
||||||
|
|
||||||
|
State Changes
|
||||||
|
=============
|
||||||
|
- Adding a new option for the State compiler, ``disabled_requisites`` will allow
|
||||||
|
requisites to be disabled during State runs.
|
||||||
|
|
|
@ -925,6 +925,7 @@ VALID_OPTS = immutabletypes.freeze(
|
||||||
# Allow raw_shell option when using the ssh
|
# Allow raw_shell option when using the ssh
|
||||||
# client via the Salt API
|
# client via the Salt API
|
||||||
"netapi_allow_raw_shell": bool,
|
"netapi_allow_raw_shell": bool,
|
||||||
|
"disabled_requisites": [],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1216,6 +1217,7 @@ DEFAULT_MINION_OPTS = immutabletypes.freeze(
|
||||||
"discovery": False,
|
"discovery": False,
|
||||||
"schedule": {},
|
"schedule": {},
|
||||||
"ssh_merge_pillar": True,
|
"ssh_merge_pillar": True,
|
||||||
|
"disabled_requisites": [],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1683,7 +1683,9 @@ class State(object):
|
||||||
)
|
)
|
||||||
extend = {}
|
extend = {}
|
||||||
errors = []
|
errors = []
|
||||||
disabled = self.opts.get("disabled_requisites", [])
|
disabled_reqs = self.opts.get("disabled_requisites", [])
|
||||||
|
if not isinstance(disabled_reqs, list):
|
||||||
|
disabled_reqs = [disabled_reqs]
|
||||||
for id_, body in six.iteritems(high):
|
for id_, body in six.iteritems(high):
|
||||||
if not isinstance(body, dict):
|
if not isinstance(body, dict):
|
||||||
continue
|
continue
|
||||||
|
@ -1702,9 +1704,10 @@ class State(object):
|
||||||
key = next(iter(arg))
|
key = next(iter(arg))
|
||||||
if key not in req_in:
|
if key not in req_in:
|
||||||
continue
|
continue
|
||||||
log.debug("=== self %s ===", self.opts)
|
if key in disabled_reqs:
|
||||||
if key in disabled:
|
log.warning(
|
||||||
log.info("=== %s disabled ===", key)
|
"The %s requisite has been disabled, Ignoring.", key
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
rkey = key.split("_")[0]
|
rkey = key.split("_")[0]
|
||||||
items = arg[key]
|
items = arg[key]
|
||||||
|
@ -2547,6 +2550,9 @@ class State(object):
|
||||||
Look into the running data to check the status of all requisite
|
Look into the running data to check the status of all requisite
|
||||||
states
|
states
|
||||||
"""
|
"""
|
||||||
|
disabled_reqs = self.opts.get("disabled_requisites", [])
|
||||||
|
if not isinstance(disabled_reqs, list):
|
||||||
|
disabled_reqs = [disabled_reqs]
|
||||||
present = False
|
present = False
|
||||||
# If mod_watch is not available make it a require
|
# If mod_watch is not available make it a require
|
||||||
if "watch" in low:
|
if "watch" in low:
|
||||||
|
@ -2598,6 +2604,9 @@ class State(object):
|
||||||
if pre:
|
if pre:
|
||||||
reqs["prerequired"] = []
|
reqs["prerequired"] = []
|
||||||
for r_state in reqs:
|
for r_state in reqs:
|
||||||
|
if r_state in disabled_reqs:
|
||||||
|
log.warning("The %s requisite has been disabled, Ignoring.", r_state)
|
||||||
|
continue
|
||||||
if r_state in low and low[r_state] is not None:
|
if r_state in low and low[r_state] is not None:
|
||||||
for req in low[r_state]:
|
for req in low[r_state]:
|
||||||
if isinstance(req, six.string_types):
|
if isinstance(req, six.string_types):
|
||||||
|
|
Loading…
Add table
Reference in a new issue