--- # The task finds the latest result file in case there are more of them # e.g. refstack-client was already executed in the current env - name: Find the test result json file ansible.builtin.find: path: "{{ refstack_client_source }}/.tempest/.stestr" patterns: '*.json' register: ls_out - when: upload_results | bool block: # refstack doesn't allow annonymous results uploading anymore, therefore # this task copies user's key to the target machine (if needed) so that it # can be used in the following task which uploads the result to the user's # refstack account - name: Copy private key block: - name: Copy private key from local machine ansible.builtin.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 ansible.builtin.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 ansible.builtin.shell: | set -ex source .venv/bin/activate refstack-client upload -y "{{ ls_out.files[-(item[0] | int + 1) | int].path }}" \ --url {{ server }} \ -i {{ private_key_path }} register: upload_out args: chdir: "{{ refstack_client_source }}" executable: /bin/bash with_indexed_items: "{{ refstack_target_programs }}" when: - private_key_path is defined - name: Print output of the upload command ansible.builtin.debug: msg: "{{ upload_out }}" # this becomes handy when the role is executed on a remote node from # an executor node (e.g. a Jenkins job) when the below artifacts might be # needed for a further processing (e.g. part of log collection of the job) - when: download_artifacts | bool block: - name: Download results file in .json ansible.builtin.fetch: src: "{{ ls_out.files[-(item[0] | int + 1) | int].path }}" dest: "{{ dest_dir }}/test_results{{ (item[0] | int + 1) | int }}.json" flat: true with_indexed_items: "{{ refstack_target_programs }}" - name: Download results file in subunit ansible.builtin.fetch: src: "{{ ls_out.files[-(item[0] | int + 1) | int].path | splitext | first }}" dest: "{{ dest_dir }}/test_results_subunit {{ (item[0] | int + 1) | int }}" flat: true with_indexed_items: "{{ refstack_target_programs }}" - name: Dump output of upload command ansible.builtin.copy: content: "{{ upload_out }}" dest: "{{ dest_dir }}/upload_output.txt" mode: '0644' delegate_to: localhost when: upload_results | bool - name: Download tempest_admin.conf file ansible.builtin.fetch: src: "{{ path_to_admin_tempest_config }}" dest: "{{ dest_dir }}/tempest_admin.conf" flat: true - name: Download tempest.conf file ansible.builtin.fetch: src: "{{ path_to_tempest_config }}" dest: "{{ dest_dir }}/tempest.conf" flat: true - name: Download accounts.yaml file ansible.builtin.fetch: src: "{{ path_to_accounts_file }}" dest: "{{ dest_dir }}/accounts.yaml" flat: true