mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make sure setting list_user_permissions to ['', '', ''] doesn't stacktrace
And doesn't report changes on secondary state runs. Fixes #28971
This commit is contained in:
parent
a7afa7a368
commit
272cc653ca
2 changed files with 21 additions and 3 deletions
|
@ -81,7 +81,8 @@ def _strip_listing_to_done(output_list):
|
|||
|
||||
|
||||
def _output_to_dict(cmdoutput, values_mapper=None):
|
||||
'''Convert rabbitmqctl output to a dict of data
|
||||
'''
|
||||
Convert rabbitmqctl output to a dict of data
|
||||
cmdoutput: string output of rabbitmqctl commands
|
||||
values_mapper: function object to process the values part of each line
|
||||
'''
|
||||
|
@ -93,7 +94,18 @@ def _output_to_dict(cmdoutput, values_mapper=None):
|
|||
data_rows = _strip_listing_to_done(cmdoutput.splitlines())
|
||||
|
||||
for row in data_rows:
|
||||
key, values = row.split('\t', 1)
|
||||
try:
|
||||
key, values = row.split('\t', 1)
|
||||
except ValueError:
|
||||
# If we have reached this far, we've hit an edge case where the row
|
||||
# only has one item: the key. The key doesn't have any values, so we
|
||||
# set it to an empty string to preserve rabbitmq reporting behavior.
|
||||
# e.g. A user's permission string for '/' is set to ['', '', ''],
|
||||
# Rabbitmq reports this only as '/' from the rabbitmqctl command.
|
||||
log.debug('Could not find any values for key \'{0}\'. '
|
||||
'Setting to \'{0}\' to an empty string.'.format(row))
|
||||
ret[row] = ''
|
||||
continue
|
||||
ret[key] = values_mapper(values)
|
||||
return ret
|
||||
|
||||
|
|
|
@ -59,7 +59,13 @@ def _check_perms_changes(name, newperms, runas=None, existing=None):
|
|||
for vhost_perms in newperms:
|
||||
for vhost, perms in vhost_perms.iteritems():
|
||||
if vhost in existing:
|
||||
if perms != existing[vhost]:
|
||||
existing_vhost = existing[vhost]
|
||||
if perms != existing_vhost:
|
||||
# This checks for setting permissions to nothing in the state,
|
||||
# when previous state runs have already set permissions to
|
||||
# nothing. We don't want to report a change in this case.
|
||||
if existing_vhost == '' and perms == ['', '', '']:
|
||||
continue
|
||||
perm_need_change = True
|
||||
else:
|
||||
perm_need_change = True
|
||||
|
|
Loading…
Add table
Reference in a new issue