mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
parent
f20c0e42ce
commit
da8a2f5cb3
@ -297,6 +297,10 @@ def append(key, val, convert=False, delimiter=':'):
|
||||
return 'The key {0} is not a valid list'.format(key)
|
||||
if val in grains:
|
||||
return 'The val {0} was already in the list {1}'.format(val, key)
|
||||
if isinstance(val, list):
|
||||
for item in val:
|
||||
grains.append(item)
|
||||
else:
|
||||
grains.append(val)
|
||||
|
||||
while delimiter in key:
|
||||
|
@ -103,7 +103,11 @@ def list_present(name, value):
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Grain {0} is not a valid list'.format(name)
|
||||
return ret
|
||||
|
||||
if isinstance(value, list):
|
||||
if set(value).issubset(set(__grains__.get(name))):
|
||||
ret['comment'] = 'Value {1} is already in grain {0}'.format(name, value)
|
||||
return ret
|
||||
else:
|
||||
if value in grain:
|
||||
ret['comment'] = 'Value {1} is already in grain {0}'.format(name, value)
|
||||
return ret
|
||||
@ -118,8 +122,13 @@ def list_present(name, value):
|
||||
ret['comment'] = 'Grain {0} is set to be added'.format(name)
|
||||
ret['changes'] = {'new': grain}
|
||||
return ret
|
||||
|
||||
new_grains = __salt__['grains.append'](name, value)
|
||||
if isinstance(value, list):
|
||||
if not set(value).issubset(set(__grains__.get(name))):
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Failed append value {1} to grain {0}'.format(name, value)
|
||||
return ret
|
||||
else:
|
||||
if value not in __grains__.get(name):
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Failed append value {1} to grain {0}'.format(name, value)
|
||||
|
Loading…
Reference in New Issue
Block a user