Repository: ansible-collections/community.general

Issue:
Add client certificate support to maven_artifact
<!--- Verify first that your feature was not already discussed on GitHub -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
<!--- Describe the new feature/improvement briefly below -->
Add client certificates to the maven_artifact module.
##### ISSUE TYPE
- Feature Idea

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
maven_artifact
##### ADDITIONAL INFORMATION
<!--- Describe how the feature would be used, why it is needed and what it would solve -->
It is possible to require a client cert to call private maven repositoy. The current maven_artifact module does not support client certificates. The get_url module does support client_cert and client_key. In the background maven_artifact and get_url use the same fetch_url. Could the client_cert and client_key features could also be added to maven_artifact module?
<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- name: Current Maven Artifact
  maven_artifact:
    group_id: com.company
    artifact_id: library-name
    repository_url: 'https://private.repo'
    dest: /tmp/library-name-latest.jar
- name: Suggested addition to Maven Artifact
  maven_artifact:
    group_id: com.company
    artifact_id: library-name
    repository_url: 'https://private.repo'
    dest: /tmp/library-name-latest.jar\
    client_cert: /path/to/client_cert.pem
    client_key: /path/to/client_key.pem
```

<!--- HINT: You can also paste gist.github.com links for larger files -->



Discussion:
That should not be hard to add. It should suffice to add the parameters to the argument_spec and to the documentation. Do you want to give it a try? :)
Sure I can give it a try.
cc @tumbl3w33d @turb
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/packaging/language/maven_artifact.py b/plugins/modules/packaging/language/maven_artifact.py
--- a/plugins/modules/packaging/language/maven_artifact.py
+++ b/plugins/modules/packaging/language/maven_artifact.py
@@ -95,6 +95,18 @@
             - If C(no), SSL certificates will not be validated. This should only be set to C(no) when no other option exists.
         type: bool
         default: 'yes'
+    client_cert:
+        description:
+            - PEM formatted certificate chain file to be used for SSL client authentication.
+            - This file can also include the key as well, and if the key is included, I(client_key) is not required.
+        type: path
+        version_added: '1.3.0'
+    client_key:
+        description:
+            - PEM formatted file that contains your private key to be used for SSL client authentication.
+            - If I(client_cert) contains both the certificate and key, this option is not required.
+        type: path
+        version_added: '1.3.0'
     keep_name:
         description:
             - If C(yes), the downloaded artifact's name is preserved, i.e the version number remains part of it.
@@ -143,6 +155,15 @@
     password: pass
     dest: /tmp/library-name-latest.jar
 
+- name: Download an artifact from a private repository requiring certificate authentication
+  community.general.maven_artifact:
+    group_id: com.company
+    artifact_id: library-name
+    repository_url: 'https://repo.company.com/maven'
+    client_cert: /path/to/cert.pem
+    client_key: /path/to/key.pem
+    dest: /tmp/library-name-latest.jar
+
 - name: Download a WAR File to the Tomcat webapps directory to be deployed
   community.general.maven_artifact:
     group_id: com.company
@@ -552,6 +573,8 @@ def main():
             timeout=dict(default=10, type='int'),
             dest=dict(type="path", required=True),
             validate_certs=dict(required=False, default=True, type='bool'),
+            client_cert=dict(type="path", required=False),
+            client_key=dict(type="path", required=False),
             keep_name=dict(required=False, default=False, type='bool'),
             verify_checksum=dict(required=False, default='download', choices=['never', 'download', 'change', 'always']),
             directory_mode=dict(type='str'),  # Used since https://github.com/ansible/ansible/pull/24965, not sure


Test patch: