Fix test mode for mount state if device_name_regex is used.

If mount.mounted is used for NFS or ceph-fuse, device_name_regex is
often needed to avoid remounting every time. If run with test=True, Salt
is always telling that it needs to remount while it is not remounting if
run with test=False. This commit changes the order of checks to first
check for a matching regex and then for the test mode and not the other
way around.
This commit is contained in:
Torsten Casselt 2018-11-07 08:27:57 +01:00
parent c2fda9dd9c
commit 56d5a32ca4
No known key found for this signature in database
GPG key ID: DBC0AD7623EBCC4E

View file

@ -515,16 +515,16 @@ def mounted(name,
if re.match(regex, _device):
_device_mismatch_is_ignored = _device
break
if __opts__['test']:
ret['result'] = None
ret['comment'] = "An umount would have been forced " \
+ "because devices do not match. Watched: " \
+ device
elif _device_mismatch_is_ignored:
if _device_mismatch_is_ignored:
ret['result'] = True
ret['comment'] = "An umount will not be forced " \
+ "because device matched device_name_regex: " \
+ _device_mismatch_is_ignored
elif __opts__['test']:
ret['result'] = None
ret['comment'] = "An umount would have been forced " \
+ "because devices do not match. Watched: " \
+ device
else:
ret['changes']['umount'] = "Forced unmount because devices " \
+ "don't match. Wanted: " + device