mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
fixes saltstack/salt#62556 mount.mounted options are order specific for persist
This commit is contained in:
parent
ad9caa92e1
commit
6e1277ae4c
4 changed files with 34 additions and 7 deletions
1
changelog/62556.fixed
Normal file
1
changelog/62556.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
Fix order specific mount.mounted options for persist
|
|
@ -368,7 +368,12 @@ class _fstab_entry:
|
|||
"""
|
||||
entry = self.dict_from_line(line)
|
||||
for key, value in self.criteria.items():
|
||||
if entry[key] != value:
|
||||
if key == "opts":
|
||||
ex_opts = sorted(entry.get(key, "").split(","))
|
||||
cr_opts = sorted(value.split(","))
|
||||
if ex_opts != cr_opts:
|
||||
return False
|
||||
elif entry[key] != value:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -467,7 +472,12 @@ class _vfstab_entry:
|
|||
"""
|
||||
entry = self.dict_from_line(line)
|
||||
for key, value in self.criteria.items():
|
||||
if entry[key] != value:
|
||||
if key == "opts":
|
||||
ex_opts = sorted(entry.get(key, "").split(","))
|
||||
cr_opts = sorted(value.split(","))
|
||||
if ex_opts != cr_opts:
|
||||
return False
|
||||
elif entry[key] != value:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -628,7 +638,12 @@ class _FileSystemsEntry:
|
|||
evalue_dict = fsys_view[1]
|
||||
for key, value in self.criteria.items():
|
||||
if key in evalue_dict:
|
||||
if evalue_dict[key] != value:
|
||||
if key == "opts":
|
||||
ex_opts = sorted(evalue_dict.get(key, "").split(","))
|
||||
cr_opts = sorted(value.split(","))
|
||||
if ex_opts != cr_opts:
|
||||
return False
|
||||
elif evalue_dict[key] != value:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
@ -867,6 +882,9 @@ def set_fstab(
|
|||
line = salt.utils.stringutils.to_unicode(line)
|
||||
try:
|
||||
if criteria.match(line):
|
||||
log.debug(
|
||||
"Checking ( %s ) against current line ( %s )", entry, line
|
||||
)
|
||||
# Note: If ret isn't None here,
|
||||
# we've matched multiple lines
|
||||
ret = "present"
|
||||
|
|
|
@ -222,8 +222,6 @@ def mounted(
|
|||
# string
|
||||
if isinstance(opts, str):
|
||||
opts = opts.split(",")
|
||||
if opts:
|
||||
opts.sort()
|
||||
|
||||
if isinstance(hidden_opts, str):
|
||||
hidden_opts = hidden_opts.split(",")
|
||||
|
@ -345,8 +343,6 @@ def mounted(
|
|||
if label_device and label_device not in device_list:
|
||||
device_list.append(label_device)
|
||||
if opts:
|
||||
opts.sort()
|
||||
|
||||
mount_invisible_options = [
|
||||
"_netdev",
|
||||
"actimeo",
|
||||
|
|
|
@ -137,6 +137,18 @@ def test_active():
|
|||
assert mount.active() == {}
|
||||
|
||||
|
||||
def test_fstab_entry_ignores_opt_ordering():
|
||||
entry = mount._fstab_entry(
|
||||
name="/tmp",
|
||||
device="tmpfs",
|
||||
fstype="tmpfs",
|
||||
opts="defaults,nodev,noexec",
|
||||
dump=0,
|
||||
pass_num=0,
|
||||
)
|
||||
assert entry.match("tmpfs\t\t/tmp\ttmpfs\tnodev,defaults,noexec\t0 0\n")
|
||||
|
||||
|
||||
def test_fstab():
|
||||
"""
|
||||
List the content of the fstab
|
||||
|
|
Loading…
Add table
Reference in a new issue