Repository: ansible/ansible-lint

Issue:
false positive on apt_key with data field
# Issue Type
- Bug report

# Ansible and Ansible Lint details

```
$ ansible --version
ansible 2.7.4
  config file = /home/lae/.ansible.cfg
  configured module search path = ['/home/lae/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.1 (default, Oct 22 2018, 10:41:28) [GCC 8.2.1 20180831]
$ ansible-lint --version
ansible-lint 4.0.0a1
```

- ansible installation method: OS
- ansible-lint installation method: pip

# Desired Behaviour

Rule 405 is meant for remote connections but using `apt_key` with the `data` field doesn't require network connectivity (not sure if there's an appropriate network lookup, but if so, that would be an exception).

# Actual Behaviour

```yaml
- name: Trust Proxmox' packaging key
  apt_key:
    data: "{{ lookup('file', pve_release_key) }}"
    id: "{{ pve_release_key_id }}"
    state: present
```

The above results in the following.

```
[405] Remote package tasks should have a retry
/home/lae/src/ansible-role-proxmox/tasks/main.yml:47
Task/Handler: Trust Proxmox' packaging key
```


Discussion:

Resolving patch:
diff --git a/lib/ansiblelint/rules/PackageHasRetryRule.py b/lib/ansiblelint/rules/PackageHasRetryRule.py
--- a/lib/ansiblelint/rules/PackageHasRetryRule.py
+++ b/lib/ansiblelint/rules/PackageHasRetryRule.py
@@ -76,19 +76,24 @@ class PackageHasRetryRule(AnsibleLintRule):
         "absent",
     ]
 
+    _module_ignore_parameters = [
+        "data",
+    ]
+
     _package_name_keys = [
         "name",
         "package",
         "pkg",
         "deb",
+        "key",
     ]
 
-    # attempt to find package name
     def get_package_name(self, action):
+        """Attempt to find package name."""
         for key in self._package_name_keys:
             found_package_name = action.get(key)
             if found_package_name:
-                break
+                return found_package_name
         return found_package_name
 
     def matchtask(self, file, task):
@@ -105,6 +110,12 @@ def matchtask(self, file, task):
         if is_state_whitelisted:
             return False
 
+        has_whitelisted_parameter = (
+            set(self._module_ignore_parameters).intersection(set(task['action']))
+        )
+        if has_whitelisted_parameter:
+            return False
+
         found_package_name = self.get_package_name(task['action'])
         if not found_package_name:
             return True


Test patch:
diff --git a/test/TestPackageHasRetry.py b/test/TestPackageHasRetry.py
--- a/test/TestPackageHasRetry.py
+++ b/test/TestPackageHasRetry.py
@@ -12,7 +12,7 @@
       apt:
         pkg: foo
       register: result
-      until: result|success
+      until: result is succeeded
 
     - name: remove software
       package:
@@ -33,6 +33,12 @@
       package:
         name: "/tmp/some_package.rpm"
         state: present
+
+    - name: packaging key
+      apt_key:
+        data: "{{ lookup('file', release_key) }}"
+        id: "{{ release_key_id }}"
+        state: present
 '''
 
 FAILURE = '''