From 1c2c574b92c9125f1f9b8186b9a5eb70c0866e3f Mon Sep 17 00:00:00 2001 From: Roman Popelka Date: Thu, 20 Jan 2022 14:03:16 +0100 Subject: [PATCH] private_key_path_src to contain a remote location Added option for private_key_path_src variable to contain also URL to remote location. Change-Id: I0777455078d9b5d9d878778c1f4d44a8a475838a --- README.md | 2 +- tasks/post-tasks.yaml | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ab30277..e9a0e69 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ deployment is working by passing refstack tests. | dest_dir * | False | pwd | String | Local directory where the artifact files will be stored. | | download_artifacts | False | False | Bool | Whether artifacts should be downloaded to the host or not. They will be downloaded to dest_dir location.| | guideline | False | 2021.11 | String | Specific refstack guideline. | -| private_key_path_src * | False | None | String | If defined, the key defined by the param is copied to the targeted machine to private_key_path location.| +| private_key_path_src | False | None | String | If defined, the key defined by the param is copied to the targeted machine to private_key_path location. Variable contains either a local path (the path on a machine, the playbook is executed from) or link to remote location from which the key will be downloaded.| | refstack_client_source | False | ~/.refstack-client | String | Destination where refstack-client will be cloned only if the dir doesn't exist or it's empty, otherwise it will be used as is.| | tempestconf_source | False | None | String | A path to python-tempestconf's source. If not defined, refstack-client's default is applied. | | refstack_client_version | False | HEAD | String | Version of refstack-client cloned from git. | diff --git a/tasks/post-tasks.yaml b/tasks/post-tasks.yaml index 7fd83f5..14586be 100644 --- a/tasks/post-tasks.yaml +++ b/tasks/post-tasks.yaml @@ -14,13 +14,24 @@ # can be used in the following task which uploads the result to the user's # refstack account - name: Copy private key - copy: - src: "{{ private_key_path_src }}" - dest: "{{ private_key_path }}" - mode: '0600' - when: - - private_key_path is defined - - private_key_path_src is defined + block: + - name: Copy private key from local machine + copy: + src: "{{ private_key_path_src }}" + dest: "{{ private_key_path }}" + mode: '0600' + when: + - private_key_path is defined + - private_key_path_src is defined + rescue: + - name: Copy private key from remote machine + get_url: + url: "{{ private_key_path_src }}" + dest: "{{ private_key_path }}" + mode: '0600' + when: + - private_key_path is defined + - private_key_path_src is defined - name: Upload results with signature shell: |