mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
[PR #7382/33133f3b backport][stable-7] kernel_blacklist: bugfix (#7409)
kernel_blacklist: bugfix (#7382)
* kernel_blacklist: bugfix
* add fix + changelog frag
* skip aix,freebsd,macos,osx in integration test
* Update changelogs/fragments/7382-kernel-blacklist-bugfix.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 33133f3ba9
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
ee2d7cd21b
commit
df89012081
5 changed files with 64 additions and 23 deletions
|
@ -53,7 +53,6 @@ EXAMPLES = '''
|
|||
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
||||
|
||||
|
@ -106,16 +105,10 @@ class Blacklist(StateModuleHelper):
|
|||
|
||||
def __quit_module__(self):
|
||||
if self.has_changed() and not self.module.check_mode:
|
||||
dummy, tmpfile = tempfile.mkstemp()
|
||||
try:
|
||||
os.remove(tmpfile)
|
||||
self.module.preserved_copy(self.vars.filename, tmpfile) # ensure right perms/ownership
|
||||
with open(tmpfile, 'w') as fd:
|
||||
fd.writelines(["{0}\n".format(x) for x in self.vars.lines])
|
||||
self.module.atomic_move(tmpfile, self.vars.filename)
|
||||
finally:
|
||||
if os.path.exists(tmpfile):
|
||||
os.remove(tmpfile)
|
||||
bkp = self.module.backup_local(self.vars.filename)
|
||||
with open(self.vars.filename, "w") as fd:
|
||||
fd.writelines(["{0}\n".format(x) for x in self.vars.lines])
|
||||
self.module.add_cleanup_file(bkp)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue