[PR #9052/d0b4e91c backport][stable-7] modprobe: fix --check mode not being honored for persistent option (#9069)
modprobe: fix --check mode not being honored for persistent option (#9052)
* modprobe: fix --check mode not being honored for persistent option
* Add CHANGELOG
* Update CHANGELOG
* Update changelogs/fragments/9052-modprobe-bugfix.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
---------
Co-authored-by: d-usuba <d-usuba@sakura.ad.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d0b4e91cac
)
Co-authored-by: salmon111 <campfire@kumachans.net>
stable-7
parent
e49a26b6ab
commit
2c1172d5d2
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- modprobe - fix check mode not being honored for ``persistent`` option (https://github.com/ansible-collections/community.general/issues/9051, https://github.com/ansible-collections/community.general/pull/9052).
|
|
@ -163,6 +163,7 @@ class Modprobe(object):
|
|||
def create_module_file(self):
|
||||
file_path = os.path.join(MODULES_LOAD_LOCATION,
|
||||
self.name + '.conf')
|
||||
if not self.check_mode:
|
||||
with open(file_path, 'w') as file:
|
||||
file.write(self.name + '\n')
|
||||
|
||||
|
@ -175,6 +176,7 @@ class Modprobe(object):
|
|||
def create_module_options_file(self):
|
||||
new_file_path = os.path.join(PARAMETERS_FILES_LOCATION,
|
||||
self.name + '.conf')
|
||||
if not self.check_mode:
|
||||
with open(new_file_path, 'w') as file:
|
||||
file.write(self.module_options_file_content)
|
||||
|
||||
|
@ -190,7 +192,7 @@ class Modprobe(object):
|
|||
file_content[index] = '#' + line
|
||||
content_changed = True
|
||||
|
||||
if content_changed:
|
||||
if not self.check_mode and content_changed:
|
||||
with open(modprobe_file, 'w') as file:
|
||||
file.write('\n'.join(file_content))
|
||||
|
||||
|
@ -206,7 +208,7 @@ class Modprobe(object):
|
|||
file_content[index] = '#' + line
|
||||
content_changed = True
|
||||
|
||||
if content_changed:
|
||||
if not self.check_mode and content_changed:
|
||||
with open(module_file, 'w') as file:
|
||||
file.write('\n'.join(file_content))
|
||||
|
||||
|
|
Loading…
Reference in New Issue