mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
keep track when an included file only includes sls files but is a requisite.
This commit is contained in:
parent
7fdd867d61
commit
f9e5029ae9
1 changed files with 20 additions and 2 deletions
|
@ -106,6 +106,7 @@ STATE_RUNTIME_KEYWORDS = frozenset(
|
|||
"__env__",
|
||||
"__sls__",
|
||||
"__id__",
|
||||
"__included__",
|
||||
"__orchestration_jid__",
|
||||
"__pub_user",
|
||||
"__pub_arg",
|
||||
|
@ -648,6 +649,8 @@ class Compiler:
|
|||
chunk["__sls__"] = body["__sls__"]
|
||||
if "__env__" in body:
|
||||
chunk["__env__"] = body["__env__"]
|
||||
if "__included__" in body:
|
||||
chunk["__included__"] = body["__included__"]
|
||||
chunk["__id__"] = name
|
||||
for arg in run:
|
||||
if isinstance(arg, str):
|
||||
|
@ -1676,6 +1679,8 @@ class State:
|
|||
chunk["__sls__"] = body["__sls__"]
|
||||
if "__env__" in body:
|
||||
chunk["__env__"] = body["__env__"]
|
||||
if "__included__" in body:
|
||||
chunk["__included__"] = body["__included__"]
|
||||
chunk["__id__"] = name
|
||||
for arg in run:
|
||||
if isinstance(arg, str):
|
||||
|
@ -2885,7 +2890,9 @@ class State:
|
|||
for chunk in chunks:
|
||||
if req_key == "sls":
|
||||
# Allow requisite tracking of entire sls files
|
||||
if fnmatch.fnmatch(chunk["__sls__"], req_val):
|
||||
if fnmatch.fnmatch(
|
||||
chunk["__sls__"], req_val
|
||||
) or req_val in chunk.get("__included__", []):
|
||||
found = True
|
||||
reqs[r_state].append(chunk)
|
||||
continue
|
||||
|
@ -3100,7 +3107,9 @@ class State:
|
|||
continue
|
||||
if req_key == "sls":
|
||||
# Allow requisite tracking of entire sls files
|
||||
if fnmatch.fnmatch(chunk["__sls__"], req_val):
|
||||
if fnmatch.fnmatch(
|
||||
chunk["__sls__"], req_val
|
||||
) or req_val in chunk.get("__included__", []):
|
||||
if requisite == "prereq":
|
||||
chunk["__prereq__"] = True
|
||||
reqs.append(chunk)
|
||||
|
@ -4298,6 +4307,9 @@ class BaseHighState:
|
|||
else:
|
||||
include = state.pop("include")
|
||||
|
||||
# Keep track if the state only includes includes
|
||||
empty_state_dict = len(state) == 0
|
||||
|
||||
self._handle_extend(state, sls, saltenv, errors)
|
||||
self._handle_exclude(state, sls, saltenv, errors)
|
||||
self._handle_state_decls(state, sls, saltenv, errors)
|
||||
|
@ -4398,6 +4410,12 @@ class BaseHighState:
|
|||
context=context,
|
||||
)
|
||||
if nstate:
|
||||
if empty_state_dict:
|
||||
for item in nstate:
|
||||
if "__included__" not in nstate[item]:
|
||||
nstate[item]["__included__"] = []
|
||||
nstate[item]["__included__"].append(sls)
|
||||
|
||||
self.merge_included_states(state, nstate, errors)
|
||||
state.update(nstate)
|
||||
if err:
|
||||
|
|
Loading…
Add table
Reference in a new issue