Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Backport 52962) mount: add not_change parameter to set_fstab and similars #55516

Merged
merged 2 commits into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions salt/modules/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,15 @@ def set_fstab(
config='/etc/fstab',
test=False,
match_on='auto',
not_change=False,
**kwargs):
'''
Verify that this mount is represented in the fstab, change the mount
to match the data passed, or add the mount if it is not present.

If the entry is found via `match_on` and `not_change` is True, the
current line will be preserved.

CLI Example:

.. code-block:: bash
Expand Down Expand Up @@ -793,7 +797,7 @@ def set_fstab(
# Note: If ret isn't None here,
# we've matched multiple lines
ret = 'present'
if entry.match(line):
if entry.match(line) or not_change:
lines.append(line)
else:
ret = 'change'
Expand Down Expand Up @@ -837,12 +841,16 @@ def set_vfstab(
config='/etc/vfstab',
test=False,
match_on='auto',
not_change=False,
**kwargs):
'''
..verionadded:: 2016.3.2
Verify that this mount is represented in the fstab, change the mount
to match the data passed, or add the mount if it is not present.

If the entry is found via `match_on` and `not_change` is True, the
current line will be preserved.

CLI Example:

.. code-block:: bash
Expand Down Expand Up @@ -922,7 +930,7 @@ def set_vfstab(
# Note: If ret isn't None here,
# we've matched multiple lines
ret = 'present'
if entry.match(line):
if entry.match(line) or not_change:
lines.append(line)
else:
ret = 'change'
Expand Down Expand Up @@ -1023,6 +1031,7 @@ def set_automaster(
opts='',
config='/etc/auto_salt',
test=False,
not_change=False,
**kwargs):
'''
Verify that this mount is represented in the auto_salt, change the mount
Expand Down Expand Up @@ -1071,9 +1080,11 @@ def set_automaster(
lines.append(line)
continue
if comps[0] == name or comps[2] == device_fmt:
present = True
if not_change:
continue
# check to see if there are changes
# and fix them if there are any
present = True
if comps[0] != name:
change = True
comps[0] = name
Expand Down Expand Up @@ -1672,13 +1683,17 @@ def set_filesystems(
config='/etc/filesystems',
test=False,
match_on='auto',
not_change=False,
**kwargs):
'''
.. versionadded:: 2018.3.3

Verify that this mount is represented in the filesystems, change the mount
to match the data passed, or add the mount if it is not present on AIX

If the entry is found via `match_on` and `not_change` is True, the
current line will be preserved.

Provide information if the path is mounted

:param name: The name of the mount point where the device is mounted.
Expand Down Expand Up @@ -1778,7 +1793,7 @@ def set_filesystems(
for fsys_view in six.viewitems(fsys_filedict):
if criteria.match(fsys_view):
ret = 'present'
if entry_ip.match(fsys_view):
if entry_ip.match(fsys_view) or not_change:
view_lines.append(fsys_view)
else:
ret = 'change'
Expand Down
Loading