We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
kernel_blacklist - Error while setting attributes: /tmp/xyz: Operation not supported
### Summary

I wanted to blacklist some kernel modules using the ready-made kernel_blacklist in Ansible.

My sample code:
```yaml
- name: Remove potentially affected (and unused) modules
  community.general.kernel_blacklist:
    name: "{{ line_item }}"
    state: present
    blacklist_file: "/etc/modprobe.d/{{ line_item }}-blacklist.conf"
  with_items:
    - cifs
    - cls_rsvp
  loop_control:
    loop_var: line_item
```

As I understand it, the module should create such a file and add content to it.

As a result, when you run the playbook, the files are created but their contents are empty:
```bash
$ find /etc/modprobe.d/ -size 0 -ls
  6030631      0 -rw-r--r--   1 root     root            0 paź  7 12:19 /etc/modprobe.d/cls_rsvp-blacklist.conf
  6029638      0 -rw-r--r--   1 root     root            0 paź  7 12:19 /etc/modprobe.d/cifs-blacklist.conf
```

Additionally, when launching the playbook, I receive a failure message. Below traceback ( -vvv)
```
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.general.kernel_blacklist_payload_rk2m8l96/ansible_community.general.kernel_blacklist_payload.zip/ansible/module_utils/basic.py", line 1003, in set_attributes_if_different
    raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /tmp/tmpnholykn5: Operation not supported

failed: [local] (item=cls_rsvp) => {
    "ansible_loop_var": "line_item",
    "changed": false,
    "details": "Error while setting attributes: /tmp/tmpnholykn5: Operation not supported\n",
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "blacklist_file": "/etc/modprobe.d/cls_rsvp-blacklist.conf",
            "name": "cls_rsvp",
            "state": "present"
        }
    },
    "line_item": "cls_rsvp",
    "mode": "0644",
    "msg": "chattr failed",
    "owner": "root",
    "path": "/tmp/tmpnholykn5",
    "size": 0,
    "state": "file",
    "uid": 0
}
```

I don't know why module display `Error while setting attributes: /tmp/tmpwn_d8ybv: Operation not supported`. 
In bash shell work perfect:
```bash
# rm -fv /etc/modprobe.d/cifs-blacklist.conf
removed '/etc/modprobe.d/cifs-blacklist.conf'
# touch /etc/modprobe.d/cifs-blacklist.conf
# echo 'test test' > /etc/modprobe.d/cifs-blacklist.conf
```

### Issue Type

Bug Report

### Component Name

kernel_blacklist

### Ansible Version

```bash
$ ansible --version
ansible [core 2.14.10]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/bkida/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/bkida/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.5 (main, Aug 28 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
```


### Community.general Version

```bash
$ ansible-galaxy collection list community.general

# /usr/lib/python3.11/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.6.2  

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.6.0  

```


### Configuration

```bash
$ ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg
```


### OS / Environment

Fedora 38

### Steps to Reproduce

Copy example code from summary description and run on the same ansible / community.general version

### Expected Results

Working module ;)

### Actual Results

`Error while setting attributes: /tmp/tmpwn_d8ybv: Operation not supported`

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `plugins/modules/kernel_blacklist.py`
Content:
```
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 
4 # Copyright (c) 2021, Alexei Znamensky (@russoz) <russoz@gmail.com>
5 # Copyright (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
6 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
7 # SPDX-License-Identifier: GPL-3.0-or-later
8 
9 from __future__ import absolute_import, division, print_function
10 __metaclass__ = type
11 
12 DOCUMENTATION = '''
13 ---
14 module: kernel_blacklist
15 author:
16     - Matthias Vogelgesang (@matze)
17 short_description: Blacklist kernel modules
18 description:
19     - Add or remove kernel modules from blacklist.
20 extends_documentation_fragment:
21     - community.general.attributes
22 attributes:
23     check_mode:
24         support: full
25     diff_mode:
26         support: full
27 options:
28     name:
29         type: str
30         description:
31             - Name of kernel module to black- or whitelist.
32         required: true
33     state:
34         type: str
35         description:
36             - Whether the module should be present in the blacklist or absent.
37         choices: [ absent, present ]
38         default: present
39     blacklist_file:
40         type: str
41         description:
42             - If specified, use this blacklist file instead of
43               C(/etc/modprobe.d/blacklist-ansible.conf).
44         default: /etc/modprobe.d/blacklist-ansible.conf
45 '''
46 
47 EXAMPLES = '''
48 - name: Blacklist the nouveau driver module
49   community.general.kernel_blacklist:
50     name: nouveau
51     state: present
52 '''
53 
54 import os
55 import re
56 import tempfile
57 
58 from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
59 
60 
61 class Blacklist(StateModuleHelper):
62     output_params = ('name', 'state')
63     module = dict(
64         argument_spec=dict(
65             name=dict(type='str', required=True),
66             state=dict(type='str', default='present', choices=['absent', 'present']),
67             blacklist_file=dict(type='str', default='/etc/modprobe.d/blacklist-ansible.conf'),
68         ),
69         supports_check_mode=True,
70     )
71 
72     def __init_module__(self):
73         self.pattern = re.compile(r'^blacklist\s+{0}$'.format(re.escape(self.vars.name)))
74         self.vars.filename = self.vars.blacklist_file
75         self.vars.set('file_exists', os.path.exists(self.vars.filename), output=False, change=True)
76         if not self.vars.file_exists:
77             with open(self.vars.filename, 'a'):
78                 pass
79             self.vars.file_exists = True
80             self.vars.set('lines', [], change=True, diff=True)
81         else:
82             with open(self.vars.filename) as fd:
83                 self.vars.set('lines', [x.rstrip() for x in fd.readlines()], change=True, diff=True)
84         self.vars.set('is_blacklisted', self._is_module_blocked(), change=True)
85 
86     def _is_module_blocked(self):
87         for line in self.vars.lines:
88             stripped = line.strip()
89             if stripped.startswith('#'):
90                 continue
91             if self.pattern.match(stripped):
92                 return True
93         return False
94 
95     def state_absent(self):
96         if not self.vars.is_blacklisted:
97             return
98         self.vars.is_blacklisted = False
99         self.vars.lines = [line for line in self.vars.lines if not self.pattern.match(line.strip())]
100 
101     def state_present(self):
102         if self.vars.is_blacklisted:
103             return
104         self.vars.is_blacklisted = True
105         self.vars.lines = self.vars.lines + ['blacklist %s' % self.vars.name]
106 
107     def __quit_module__(self):
108         if self.has_changed() and not self.module.check_mode:
109             dummy, tmpfile = tempfile.mkstemp()
110             try:
111                 os.remove(tmpfile)
112                 self.module.preserved_copy(self.vars.filename, tmpfile)  # ensure right perms/ownership
113                 with open(tmpfile, 'w') as fd:
114                     fd.writelines(["{0}\n".format(x) for x in self.vars.lines])
115                 self.module.atomic_move(tmpfile, self.vars.filename)
116             finally:
117                 if os.path.exists(tmpfile):
118                     os.remove(tmpfile)
119 
120 
121 def main():
122     Blacklist.execute()
123 
124 
125 if __name__ == '__main__':
126     main()
127
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/plugins/modules/kernel_blacklist.py b/plugins/modules/kernel_blacklist.py
--- a/plugins/modules/kernel_blacklist.py
+++ b/plugins/modules/kernel_blacklist.py
@@ -53,7 +53,6 @@
 
 import os
 import re
-import tempfile
 
 from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
 
@@ -106,16 +105,10 @@
 
     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():

{"golden_diff": "diff --git a/plugins/modules/kernel_blacklist.py b/plugins/modules/kernel_blacklist.py\n--- a/plugins/modules/kernel_blacklist.py\n+++ b/plugins/modules/kernel_blacklist.py\n@@ -53,7 +53,6 @@\n \n import os\n import re\n-import tempfile\n \n from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper\n \n@@ -106,16 +105,10 @@\n \n     def __quit_module__(self):\n         if self.has_changed() and not self.module.check_mode:\n-            dummy, tmpfile = tempfile.mkstemp()\n-            try:\n-                os.remove(tmpfile)\n-                self.module.preserved_copy(self.vars.filename, tmpfile)  # ensure right perms/ownership\n-                with open(tmpfile, 'w') as fd:\n-                    fd.writelines([\"{0}\\n\".format(x) for x in self.vars.lines])\n-                self.module.atomic_move(tmpfile, self.vars.filename)\n-            finally:\n-                if os.path.exists(tmpfile):\n-                    os.remove(tmpfile)\n+            bkp = self.module.backup_local(self.vars.filename)\n+            with open(self.vars.filename, \"w\") as fd:\n+                fd.writelines([\"{0}\\n\".format(x) for x in self.vars.lines])\n+            self.module.add_cleanup_file(bkp)\n \n \n def main():\n", "issue": "kernel_blacklist - Error while setting attributes: /tmp/xyz: Operation not supported\n### Summary\n\nI wanted to blacklist some kernel modules using the ready-made kernel_blacklist in Ansible.\r\n\r\nMy sample code:\r\n```yaml\r\n- name: Remove potentially affected (and unused) modules\r\n  community.general.kernel_blacklist:\r\n    name: \"{{ line_item }}\"\r\n    state: present\r\n    blacklist_file: \"/etc/modprobe.d/{{ line_item }}-blacklist.conf\"\r\n  with_items:\r\n    - cifs\r\n    - cls_rsvp\r\n  loop_control:\r\n    loop_var: line_item\r\n```\r\n\r\nAs I understand it, the module should create such a file and add content to it.\r\n\r\nAs a result, when you run the playbook, the files are created but their contents are empty:\r\n```bash\r\n$ find /etc/modprobe.d/ -size 0 -ls\r\n  6030631      0 -rw-r--r--   1 root     root            0 pa\u017a  7 12:19 /etc/modprobe.d/cls_rsvp-blacklist.conf\r\n  6029638      0 -rw-r--r--   1 root     root            0 pa\u017a  7 12:19 /etc/modprobe.d/cifs-blacklist.conf\r\n```\r\n\r\nAdditionally, when launching the playbook, I receive a failure message. Below traceback ( -vvv)\r\n```\r\nThe full traceback is:\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_community.general.kernel_blacklist_payload_rk2m8l96/ansible_community.general.kernel_blacklist_payload.zip/ansible/module_utils/basic.py\", line 1003, in set_attributes_if_different\r\n    raise Exception(\"Error while setting attributes: %s\" % (out + err))\r\nException: Error while setting attributes: /tmp/tmpnholykn5: Operation not supported\r\n\r\nfailed: [local] (item=cls_rsvp) => {\r\n    \"ansible_loop_var\": \"line_item\",\r\n    \"changed\": false,\r\n    \"details\": \"Error while setting attributes: /tmp/tmpnholykn5: Operation not supported\\n\",\r\n    \"gid\": 0,\r\n    \"group\": \"root\",\r\n    \"invocation\": {\r\n        \"module_args\": {\r\n            \"blacklist_file\": \"/etc/modprobe.d/cls_rsvp-blacklist.conf\",\r\n            \"name\": \"cls_rsvp\",\r\n            \"state\": \"present\"\r\n        }\r\n    },\r\n    \"line_item\": \"cls_rsvp\",\r\n    \"mode\": \"0644\",\r\n    \"msg\": \"chattr failed\",\r\n    \"owner\": \"root\",\r\n    \"path\": \"/tmp/tmpnholykn5\",\r\n    \"size\": 0,\r\n    \"state\": \"file\",\r\n    \"uid\": 0\r\n}\r\n```\r\n\r\nI don't know why module display `Error while setting attributes: /tmp/tmpwn_d8ybv: Operation not supported`. \r\nIn bash shell work perfect:\r\n```bash\r\n# rm -fv /etc/modprobe.d/cifs-blacklist.conf\r\nremoved '/etc/modprobe.d/cifs-blacklist.conf'\r\n# touch /etc/modprobe.d/cifs-blacklist.conf\r\n# echo 'test test' > /etc/modprobe.d/cifs-blacklist.conf\r\n```\n\n### Issue Type\n\nBug Report\n\n### Component Name\n\nkernel_blacklist\n\n### Ansible Version\n\n```bash\r\n$ ansible --version\r\nansible [core 2.14.10]\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = ['/home/bkida/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/lib/python3.11/site-packages/ansible\r\n  ansible collection location = /home/bkida/.ansible/collections:/usr/share/ansible/collections\r\n  executable location = /usr/bin/ansible\r\n  python version = 3.11.5 (main, Aug 28 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/usr/bin/python3)\r\n  jinja version = 3.0.3\r\n  libyaml = True\r\n```\r\n\n\n### Community.general Version\n\n```bash\r\n$ ansible-galaxy collection list community.general\r\n\r\n# /usr/lib/python3.11/site-packages/ansible_collections\r\nCollection        Version\r\n----------------- -------\r\ncommunity.general 6.6.2  \r\n\r\n# /usr/share/ansible/collections/ansible_collections\r\nCollection        Version\r\n----------------- -------\r\ncommunity.general 6.6.0  \r\n\r\n```\r\n\n\n### Configuration\n\n```bash\r\n$ ansible-config dump --only-changed\r\nCONFIG_FILE() = /etc/ansible/ansible.cfg\r\n```\r\n\n\n### OS / Environment\n\nFedora 38\n\n### Steps to Reproduce\n\nCopy example code from summary description and run on the same ansible / community.general version\n\n### Expected Results\n\nWorking module ;)\n\n### Actual Results\n\n`Error while setting attributes: /tmp/tmpwn_d8ybv: Operation not supported`\n\n### Code of Conduct\n\n- [X] I agree to follow the Ansible Code of Conduct\n", "before_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2021, Alexei Znamensky (@russoz) <russoz@gmail.com>\n# Copyright (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@gmail.com>\n# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)\n# SPDX-License-Identifier: GPL-3.0-or-later\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\nDOCUMENTATION = '''\n---\nmodule: kernel_blacklist\nauthor:\n    - Matthias Vogelgesang (@matze)\nshort_description: Blacklist kernel modules\ndescription:\n    - Add or remove kernel modules from blacklist.\nextends_documentation_fragment:\n    - community.general.attributes\nattributes:\n    check_mode:\n        support: full\n    diff_mode:\n        support: full\noptions:\n    name:\n        type: str\n        description:\n            - Name of kernel module to black- or whitelist.\n        required: true\n    state:\n        type: str\n        description:\n            - Whether the module should be present in the blacklist or absent.\n        choices: [ absent, present ]\n        default: present\n    blacklist_file:\n        type: str\n        description:\n            - If specified, use this blacklist file instead of\n              C(/etc/modprobe.d/blacklist-ansible.conf).\n        default: /etc/modprobe.d/blacklist-ansible.conf\n'''\n\nEXAMPLES = '''\n- name: Blacklist the nouveau driver module\n  community.general.kernel_blacklist:\n    name: nouveau\n    state: present\n'''\n\nimport os\nimport re\nimport tempfile\n\nfrom ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper\n\n\nclass Blacklist(StateModuleHelper):\n    output_params = ('name', 'state')\n    module = dict(\n        argument_spec=dict(\n            name=dict(type='str', required=True),\n            state=dict(type='str', default='present', choices=['absent', 'present']),\n            blacklist_file=dict(type='str', default='/etc/modprobe.d/blacklist-ansible.conf'),\n        ),\n        supports_check_mode=True,\n    )\n\n    def __init_module__(self):\n        self.pattern = re.compile(r'^blacklist\\s+{0}$'.format(re.escape(self.vars.name)))\n        self.vars.filename = self.vars.blacklist_file\n        self.vars.set('file_exists', os.path.exists(self.vars.filename), output=False, change=True)\n        if not self.vars.file_exists:\n            with open(self.vars.filename, 'a'):\n                pass\n            self.vars.file_exists = True\n            self.vars.set('lines', [], change=True, diff=True)\n        else:\n            with open(self.vars.filename) as fd:\n                self.vars.set('lines', [x.rstrip() for x in fd.readlines()], change=True, diff=True)\n        self.vars.set('is_blacklisted', self._is_module_blocked(), change=True)\n\n    def _is_module_blocked(self):\n        for line in self.vars.lines:\n            stripped = line.strip()\n            if stripped.startswith('#'):\n                continue\n            if self.pattern.match(stripped):\n                return True\n        return False\n\n    def state_absent(self):\n        if not self.vars.is_blacklisted:\n            return\n        self.vars.is_blacklisted = False\n        self.vars.lines = [line for line in self.vars.lines if not self.pattern.match(line.strip())]\n\n    def state_present(self):\n        if self.vars.is_blacklisted:\n            return\n        self.vars.is_blacklisted = True\n        self.vars.lines = self.vars.lines + ['blacklist %s' % self.vars.name]\n\n    def __quit_module__(self):\n        if self.has_changed() and not self.module.check_mode:\n            dummy, tmpfile = tempfile.mkstemp()\n            try:\n                os.remove(tmpfile)\n                self.module.preserved_copy(self.vars.filename, tmpfile)  # ensure right perms/ownership\n                with open(tmpfile, 'w') as fd:\n                    fd.writelines([\"{0}\\n\".format(x) for x in self.vars.lines])\n                self.module.atomic_move(tmpfile, self.vars.filename)\n            finally:\n                if os.path.exists(tmpfile):\n                    os.remove(tmpfile)\n\n\ndef main():\n    Blacklist.execute()\n\n\nif __name__ == '__main__':\n    main()\n", "path": "plugins/modules/kernel_blacklist.py"}], "after_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2021, Alexei Znamensky (@russoz) <russoz@gmail.com>\n# Copyright (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@gmail.com>\n# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)\n# SPDX-License-Identifier: GPL-3.0-or-later\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\nDOCUMENTATION = '''\n---\nmodule: kernel_blacklist\nauthor:\n    - Matthias Vogelgesang (@matze)\nshort_description: Blacklist kernel modules\ndescription:\n    - Add or remove kernel modules from blacklist.\nextends_documentation_fragment:\n    - community.general.attributes\nattributes:\n    check_mode:\n        support: full\n    diff_mode:\n        support: full\noptions:\n    name:\n        type: str\n        description:\n            - Name of kernel module to black- or whitelist.\n        required: true\n    state:\n        type: str\n        description:\n            - Whether the module should be present in the blacklist or absent.\n        choices: [ absent, present ]\n        default: present\n    blacklist_file:\n        type: str\n        description:\n            - If specified, use this blacklist file instead of\n              C(/etc/modprobe.d/blacklist-ansible.conf).\n        default: /etc/modprobe.d/blacklist-ansible.conf\n'''\n\nEXAMPLES = '''\n- name: Blacklist the nouveau driver module\n  community.general.kernel_blacklist:\n    name: nouveau\n    state: present\n'''\n\nimport os\nimport re\n\nfrom ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper\n\n\nclass Blacklist(StateModuleHelper):\n    output_params = ('name', 'state')\n    module = dict(\n        argument_spec=dict(\n            name=dict(type='str', required=True),\n            state=dict(type='str', default='present', choices=['absent', 'present']),\n            blacklist_file=dict(type='str', default='/etc/modprobe.d/blacklist-ansible.conf'),\n        ),\n        supports_check_mode=True,\n    )\n\n    def __init_module__(self):\n        self.pattern = re.compile(r'^blacklist\\s+{0}$'.format(re.escape(self.vars.name)))\n        self.vars.filename = self.vars.blacklist_file\n        self.vars.set('file_exists', os.path.exists(self.vars.filename), output=False, change=True)\n        if not self.vars.file_exists:\n            with open(self.vars.filename, 'a'):\n                pass\n            self.vars.file_exists = True\n            self.vars.set('lines', [], change=True, diff=True)\n        else:\n            with open(self.vars.filename) as fd:\n                self.vars.set('lines', [x.rstrip() for x in fd.readlines()], change=True, diff=True)\n        self.vars.set('is_blacklisted', self._is_module_blocked(), change=True)\n\n    def _is_module_blocked(self):\n        for line in self.vars.lines:\n            stripped = line.strip()\n            if stripped.startswith('#'):\n                continue\n            if self.pattern.match(stripped):\n                return True\n        return False\n\n    def state_absent(self):\n        if not self.vars.is_blacklisted:\n            return\n        self.vars.is_blacklisted = False\n        self.vars.lines = [line for line in self.vars.lines if not self.pattern.match(line.strip())]\n\n    def state_present(self):\n        if self.vars.is_blacklisted:\n            return\n        self.vars.is_blacklisted = True\n        self.vars.lines = self.vars.lines + ['blacklist %s' % self.vars.name]\n\n    def __quit_module__(self):\n        if self.has_changed() and not self.module.check_mode:\n            bkp = self.module.backup_local(self.vars.filename)\n            with open(self.vars.filename, \"w\") as fd:\n                fd.writelines([\"{0}\\n\".format(x) for x in self.vars.lines])\n            self.module.add_cleanup_file(bkp)\n\n\ndef main():\n    Blacklist.execute()\n\n\nif __name__ == '__main__':\n    main()\n", "path": "plugins/modules/kernel_blacklist.py"}]}