mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
The file listing needs to be sorted to return expectable results.
This seems like the only reasonable way to override, for example, grains. Grains from `custom_grains_2` should override grains from `custom_grains_1`.
This commit is contained in:
parent
3b95ef2345
commit
451d8f98e3
2 changed files with 5 additions and 1 deletions
|
@ -715,6 +715,7 @@ def grains(opts, force_refresh=False, proxy=None):
|
|||
# one parameter. Then the grains can have access to the
|
||||
# proxymodule for retrieving information from the connected
|
||||
# device.
|
||||
log.trace('Loading {0} grain'.format(key))
|
||||
if funcs[key].__code__.co_argcount == 1:
|
||||
ret = funcs[key](proxy)
|
||||
else:
|
||||
|
@ -1179,7 +1180,8 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
for mod_dir in self.module_dirs:
|
||||
files = []
|
||||
try:
|
||||
files = os.listdir(mod_dir)
|
||||
# Make sure we have a sorted listdir in order to have expectable override results
|
||||
files = sorted(os.listdir(mod_dir))
|
||||
except OSError:
|
||||
continue # Next mod_dir
|
||||
for filename in files:
|
||||
|
|
|
@ -32,6 +32,8 @@ class LoaderGrainsTest(ModuleCase):
|
|||
# self.opts['grains'] = grains(self.opts)
|
||||
|
||||
def test_grains_overwrite(self):
|
||||
# Force a grains sync
|
||||
self.run_function('saltutil.sync_grains')
|
||||
# To avoid a race condition on Windows, we need to make sure the
|
||||
# `test_custom_grain2.py` file is present in the _grains directory
|
||||
# before trying to get the grains. This test may execute before the
|
||||
|
|
Loading…
Add table
Reference in a new issue