mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #43973 from terminalmage/fix-grains.has_value
Fix grains.has_value when value is False
This commit is contained in:
commit
1d5397ab5b
1 changed files with 5 additions and 2 deletions
|
@ -121,7 +121,7 @@ def get(key, default='', delimiter=DEFAULT_TARGET_DELIM, ordered=True):
|
|||
|
||||
def has_value(key):
|
||||
'''
|
||||
Determine whether a named value exists in the grains dictionary.
|
||||
Determine whether a key exists in the grains dictionary.
|
||||
|
||||
Given a grains dictionary that contains the following structure::
|
||||
|
||||
|
@ -137,7 +137,10 @@ def has_value(key):
|
|||
|
||||
salt '*' grains.has_value pkg:apache
|
||||
'''
|
||||
return True if salt.utils.traverse_dict_and_list(__grains__, key, False) else False
|
||||
return salt.utils.traverse_dict_and_list(
|
||||
__grains__,
|
||||
key,
|
||||
KeyError) is not KeyError
|
||||
|
||||
|
||||
def items(sanitize=False):
|
||||
|
|
Loading…
Add table
Reference in a new issue