We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
E208 is too aggressive
##### Summary
When E208 is triggered, it should be sure that a file is being created. There are modules which only optionally create the file and, when not used in that form, then they should not require a mode be set. Such an example are ini_file, lineinfile, or blockinfile. These modules are frequently used in their default mode with `create: false`. Someone should not be required to set `mode: "0644"` or such in this situation.


##### Issue Type

- Bug Report

##### Ansible and Ansible Lint details
<!--- Paste verbatim output between tripple backticks -->
```console (paste below)
ansible --version
ansible 2.9.12
  config file = /home/greg/.ansible.cfg
  configured module search path = ['/home/greg/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/greg/src/ansible_collections/devroles/system/.tox/lint_all/lib/python3.8/site-packages/ansible
  executable location = .tox/lint_all/bin/ansible
  python version = 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]

ansible-lint --version
ansible-lint 4.3.1
```

- ansible installation method: one of source, pip, OS package
pip
- ansible-lint installation method: one of source, pip, OS package
pip

##### OS / ENVIRONMENT
Fedora 32


##### STEPS TO REPRODUCE
```yaml
- name: should not produce E208
  lineinfile:
    line: "# some content here"
    file: "{{ ansible_user_dir }}/.bashrc"

- name: SHOULD produce E208
  lineinfile:
    line: "# more content
    file: "{{ ansible_user_dir }}/.bash_profile"
    create: true
```
##### Desired Behaviour
ansible-lint should not error when it encounters a missing "mode" parameter for these modules, when `create: false`. Note that `create: false` is the default behavior of those modules

##### Actual Behaviour
ansible-lint throws E208 on both of the above steps

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lib/ansiblelint/rules/MissingFilePermissionsRule.py`
Content:
```
1 # Copyright (c) 2020 Sorin Sbarnea <sorin.sbarnea@gmail.com>
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 # THE SOFTWARE.
20 from ansiblelint.rules import AnsibleLintRule
21 
22 
23 class MissingFilePermissionsRule(AnsibleLintRule):
24     id = "208"
25     shortdesc = 'File permissions not mentioned'
26     description = (
27         "Missing mode parameter can cause unexpected file permissions based "
28         "on version of Ansible being used. Be explicit, or if you still "
29         "want the default behavior you can use ``mode: preserve`` to avoid "
30         "hitting this rule. See "
31         "https://github.com/ansible/ansible/issues/71200"
32     )
33     severity = 'VERY_HIGH'
34     tags = ['unpredictability']
35     version_added = 'v4.3.0'
36 
37     _modules = (
38         'copy',
39         'file',
40         'ini_file',
41         'lineinfile',
42         'replace',
43         'template',
44         'unarchive',
45     )
46 
47     def matchtask(self, file, task):
48         if task["action"]["__ansible_module__"] not in self._modules:
49             return False
50 
51         if task['action'].get('state', None) == "absent":
52             return False
53 
54         if task['action'].get('state', None) == "link":
55             return False
56 
57         mode = task['action'].get('mode', None)
58         return mode is None
59
```
--- 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/lib/ansiblelint/rules/MissingFilePermissionsRule.py b/lib/ansiblelint/rules/MissingFilePermissionsRule.py
--- a/lib/ansiblelint/rules/MissingFilePermissionsRule.py
+++ b/lib/ansiblelint/rules/MissingFilePermissionsRule.py
@@ -35,17 +35,28 @@
     version_added = 'v4.3.0'
 
     _modules = (
+        'assemble',
+        'archive',
         'copy',
         'file',
-        'ini_file',
-        'lineinfile',
         'replace',
         'template',
         'unarchive',
     )
 
+    _modules_with_create = (
+        'blockinfile',
+        'ini_file',
+        'lineinfile'
+    )
+
     def matchtask(self, file, task):
-        if task["action"]["__ansible_module__"] not in self._modules:
+        if task["action"]["__ansible_module__"] not in self._modules and \
+                task["action"]["__ansible_module__"] not in self._modules_with_create:
+            return False
+
+        if task["action"]["__ansible_module__"] in self._modules_with_create and \
+                not task["action"].get("create", False):
             return False
 
         if task['action'].get('state', None) == "absent":

{"golden_diff": "diff --git a/lib/ansiblelint/rules/MissingFilePermissionsRule.py b/lib/ansiblelint/rules/MissingFilePermissionsRule.py\n--- a/lib/ansiblelint/rules/MissingFilePermissionsRule.py\n+++ b/lib/ansiblelint/rules/MissingFilePermissionsRule.py\n@@ -35,17 +35,28 @@\n     version_added = 'v4.3.0'\n \n     _modules = (\n+        'assemble',\n+        'archive',\n         'copy',\n         'file',\n-        'ini_file',\n-        'lineinfile',\n         'replace',\n         'template',\n         'unarchive',\n     )\n \n+    _modules_with_create = (\n+        'blockinfile',\n+        'ini_file',\n+        'lineinfile'\n+    )\n+\n     def matchtask(self, file, task):\n-        if task[\"action\"][\"__ansible_module__\"] not in self._modules:\n+        if task[\"action\"][\"__ansible_module__\"] not in self._modules and \\\n+                task[\"action\"][\"__ansible_module__\"] not in self._modules_with_create:\n+            return False\n+\n+        if task[\"action\"][\"__ansible_module__\"] in self._modules_with_create and \\\n+                not task[\"action\"].get(\"create\", False):\n             return False\n \n         if task['action'].get('state', None) == \"absent\":\n", "issue": "E208 is too aggressive\n##### Summary\r\nWhen E208 is triggered, it should be sure that a file is being created. There are modules which only optionally create the file and, when not used in that form, then they should not require a mode be set. Such an example are ini_file, lineinfile, or blockinfile. These modules are frequently used in their default mode with `create: false`. Someone should not be required to set `mode: \"0644\"` or such in this situation.\r\n\r\n\r\n##### Issue Type\r\n\r\n- Bug Report\r\n\r\n##### Ansible and Ansible Lint details\r\n<!--- Paste verbatim output between tripple backticks -->\r\n```console (paste below)\r\nansible --version\r\nansible 2.9.12\r\n  config file = /home/greg/.ansible.cfg\r\n  configured module search path = ['/home/greg/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /home/greg/src/ansible_collections/devroles/system/.tox/lint_all/lib/python3.8/site-packages/ansible\r\n  executable location = .tox/lint_all/bin/ansible\r\n  python version = 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]\r\n\r\nansible-lint --version\r\nansible-lint 4.3.1\r\n```\r\n\r\n- ansible installation method: one of source, pip, OS package\r\npip\r\n- ansible-lint installation method: one of source, pip, OS package\r\npip\r\n\r\n##### OS / ENVIRONMENT\r\nFedora 32\r\n\r\n\r\n##### STEPS TO REPRODUCE\r\n```yaml\r\n- name: should not produce E208\r\n  lineinfile:\r\n    line: \"# some content here\"\r\n    file: \"{{ ansible_user_dir }}/.bashrc\"\r\n\r\n- name: SHOULD produce E208\r\n  lineinfile:\r\n    line: \"# more content\r\n    file: \"{{ ansible_user_dir }}/.bash_profile\"\r\n    create: true\r\n```\r\n##### Desired Behaviour\r\nansible-lint should not error when it encounters a missing \"mode\" parameter for these modules, when `create: false`. Note that `create: false` is the default behavior of those modules\r\n\r\n##### Actual Behaviour\r\nansible-lint throws E208 on both of the above steps\n", "before_files": [{"content": "# Copyright (c) 2020 Sorin Sbarnea <sorin.sbarnea@gmail.com>\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n# THE SOFTWARE.\nfrom ansiblelint.rules import AnsibleLintRule\n\n\nclass MissingFilePermissionsRule(AnsibleLintRule):\n    id = \"208\"\n    shortdesc = 'File permissions not mentioned'\n    description = (\n        \"Missing mode parameter can cause unexpected file permissions based \"\n        \"on version of Ansible being used. Be explicit, or if you still \"\n        \"want the default behavior you can use ``mode: preserve`` to avoid \"\n        \"hitting this rule. See \"\n        \"https://github.com/ansible/ansible/issues/71200\"\n    )\n    severity = 'VERY_HIGH'\n    tags = ['unpredictability']\n    version_added = 'v4.3.0'\n\n    _modules = (\n        'copy',\n        'file',\n        'ini_file',\n        'lineinfile',\n        'replace',\n        'template',\n        'unarchive',\n    )\n\n    def matchtask(self, file, task):\n        if task[\"action\"][\"__ansible_module__\"] not in self._modules:\n            return False\n\n        if task['action'].get('state', None) == \"absent\":\n            return False\n\n        if task['action'].get('state', None) == \"link\":\n            return False\n\n        mode = task['action'].get('mode', None)\n        return mode is None\n", "path": "lib/ansiblelint/rules/MissingFilePermissionsRule.py"}], "after_files": [{"content": "# Copyright (c) 2020 Sorin Sbarnea <sorin.sbarnea@gmail.com>\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n# THE SOFTWARE.\nfrom ansiblelint.rules import AnsibleLintRule\n\n\nclass MissingFilePermissionsRule(AnsibleLintRule):\n    id = \"208\"\n    shortdesc = 'File permissions not mentioned'\n    description = (\n        \"Missing mode parameter can cause unexpected file permissions based \"\n        \"on version of Ansible being used. Be explicit, or if you still \"\n        \"want the default behavior you can use ``mode: preserve`` to avoid \"\n        \"hitting this rule. See \"\n        \"https://github.com/ansible/ansible/issues/71200\"\n    )\n    severity = 'VERY_HIGH'\n    tags = ['unpredictability']\n    version_added = 'v4.3.0'\n\n    _modules = (\n        'assemble',\n        'archive',\n        'copy',\n        'file',\n        'replace',\n        'template',\n        'unarchive',\n    )\n\n    _modules_with_create = (\n        'blockinfile',\n        'ini_file',\n        'lineinfile'\n    )\n\n    def matchtask(self, file, task):\n        if task[\"action\"][\"__ansible_module__\"] not in self._modules and \\\n                task[\"action\"][\"__ansible_module__\"] not in self._modules_with_create:\n            return False\n\n        if task[\"action\"][\"__ansible_module__\"] in self._modules_with_create and \\\n                not task[\"action\"].get(\"create\", False):\n            return False\n\n        if task['action'].get('state', None) == \"absent\":\n            return False\n\n        if task['action'].get('state', None) == \"link\":\n            return False\n\n        mode = task['action'].get('mode', None)\n        return mode is None\n", "path": "lib/ansiblelint/rules/MissingFilePermissionsRule.py"}]}