From c826a81b40672595babb85a34ac2ea9b54b6e51a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2020 20:27:23 +0200 Subject: [PATCH] Added client_cert and client_key to the maven_artifact module. (#1127) (#1142) * Added client_cert and client_key to the maven_artifact module. * Changelog fragment for PR-1127 * Apply suggestions from code review Changes suggested in review. Match argument_spec values to documentation values. Co-authored-by: Felix Fontein * Update changelogs/fragments/1127-maven_artifact_client_cert.yml Documentation formatting suggestion. Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit 18a5330e628d8e035f4c3f3cc26e278ccbc3f71b) Co-authored-by: mdaves93 --- .../1127-maven_artifact_client_cert.yml | 2 ++ .../packaging/language/maven_artifact.py | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 changelogs/fragments/1127-maven_artifact_client_cert.yml diff --git a/changelogs/fragments/1127-maven_artifact_client_cert.yml b/changelogs/fragments/1127-maven_artifact_client_cert.yml new file mode 100644 index 0000000000..612ea04921 --- /dev/null +++ b/changelogs/fragments/1127-maven_artifact_client_cert.yml @@ -0,0 +1,2 @@ +minor_changes: + - maven_artifact - added ``client_cert`` and ``client_key`` parameters to the maven_artifact module (https://github.com/ansible-collections/community.general/issues/1123). diff --git a/plugins/modules/packaging/language/maven_artifact.py b/plugins/modules/packaging/language/maven_artifact.py index 7503f1642e..ff682e381f 100644 --- a/plugins/modules/packaging/language/maven_artifact.py +++ b/plugins/modules/packaging/language/maven_artifact.py @@ -95,6 +95,18 @@ options: - 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 @@ EXAMPLES = ''' 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