--- # These tasks are intended to be run inside a loop, where `testconfig` # is the loop parameter and can take different values in each run. - name: OCP install and test block vars: testconfig_dir_name: "{{ current_index | string + '-' + (testconfig | splitext | first) }}" testconfig_artifacts_dir: "{{ (cifmw_shiftstack_artifacts_dir, testconfig_dir_name) | path_join }}" block: - name: "Initialize the testconfig_result_dict fact for the testconfig '{{ testconfig }}'" ansible.builtin.set_fact: testconfig_result_dict: "{{ testconfig_result_dict | combine({ current_index: { testconfig : 'PASS' } }) }}" - name: "Check the test configuration file exists in the repository" vars: namespace: "{{ cifmw_shiftstack_client_pod_namespace }}" pod_name: "{{ cifmw_shiftstack_client_pod_name }}" command: >- test -f shiftstack-qa/jobs_definitions/{{ testconfig }} log_file_name: "{{ testconfig }}-find_test_config.log" ansible.builtin.include_tasks: exec_command_in_pod.yml - name: "Create the directory for the test config artifacts '{{ testconfig_artifacts_dir }}'" ansible.builtin.file: path: "{{ testconfig_artifacts_dir }}" state: directory mode: "0755" - name: "Test Openshift on Openstack with the test configuration '{{ testconfig }}'" vars: namespace: "{{ cifmw_shiftstack_client_pod_namespace }}" pod_name: "{{ cifmw_shiftstack_client_pod_name }}" command: >- source .bashrc && cd shiftstack-qa && ansible-navigator run playbooks/{{ cifmw_shiftstack_run_playbook }} -e @jobs_definitions/{{ testconfig }} {% if cifmw_shiftstack_extra_vars | length > 0 %}-e @{{ cifmw_shiftstack_extra_vars_mount_path }}/extra-vars.yaml{% endif %} -e ocp_cluster_name={{ cifmw_shiftstack_cluster_name }} -e user_cloud={{ cifmw_shiftstack_project_name }} -e hypervisor={{ cifmw_shiftstack_hypervisor }} -e rhoso_kubeconfig={{ cifmw_shiftstack_shiftstackclient_incluster_kubeconfig_dir }}/kubeconfig ansible.builtin.include_tasks: exec_command_in_pod.yml rescue: - name: "Set failure info for '{{ testconfig }}'" ansible.builtin.set_fact: failure_info: failed_task: "{{ ansible_failed_task.name }}" result_msg: "{{ ansible_failed_result.msg }}" - name: "Update the testconfig_result_dict fact with a failed status for '{{ testconfig }}'" ansible.builtin.set_fact: testconfig_result_dict: "{{ testconfig_result_dict | combine({ current_index: { testconfig : {'FAIL': failure_info} } }) }}" always: - name: "Copy the artifacts from the pod '{{ cifmw_shiftstack_client_pod_name }}'" vars: _exclude_options: >- {{ '--exclude=' ~ cifmw_shiftstack_exclude_artifacts_regex if cifmw_shiftstack_exclude_artifacts_regex | default('') != '' else '' }} environment: PATH: "{{ cifmw_path }}" KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" ansible.builtin.command: cmd: > oc rsync -n {{ cifmw_shiftstack_client_pod_namespace }} {{ _exclude_options }} {{ cifmw_shiftstack_client_pod_name }}:{{ cifmw_shiftstack_shiftstackclient_artifacts_dir }}/ {{ testconfig_artifacts_dir }}/ failed_when: false