From e53622f51cbf3db7e289f3c42187aafa599d2d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Lobillo?= Date: Tue, 26 Nov 2024 21:49:10 +0100 Subject: [PATCH] [shiftstack]Enable the option to run the role isolated In order to allow users to run the shiftsatck role without being part of the whole reproducer, below changes are needed: - Add missing kubeconfig param - Load .bashrc whle running the ansible-navigator. That's needed for reading the envvars that will be used for writting the junit report. - Enable the option to exclude artifacts to be gathered. --- roles/shiftstack/README.md | 1 + roles/shiftstack/defaults/main.yml | 1 + roles/shiftstack/molecule/default/converge.yml | 1 + roles/shiftstack/tasks/pre_test_shiftstack.yml | 1 + roles/shiftstack/tasks/test_config.yml | 10 +++++++++- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/roles/shiftstack/README.md b/roles/shiftstack/README.md index 737d776741..d15e94a4f6 100644 --- a/roles/shiftstack/README.md +++ b/roles/shiftstack/README.md @@ -13,6 +13,7 @@ Role for triggering Openshift on Openstack QA automation (installation and tests * `cifmw_shiftstack_client_pod_image`: (*string*) The image for the container running in the `cifmw_shiftstack_client_pod_name` pod. Defaults to `quay.io/shiftstack-qe/shiftstack-client:latest`. * `cifmw_shiftstack_client_pvc_manifest`: (*string*) The file name for the shiftstackclient pvc manifest. Defaults to `"{{ cifmw_shiftstack_client_pod_name }}_pvc.yml"`. * `cifmw_shiftstack_cluster_name`: (*string*) The Openshift cluster name. Defaults to `ostest`. +* `cifmw_shiftstack_exclude_artifacts_regex`: (*string*) Regex that will be passed on `oc rsync` command as `--exclude` param, so the role does not gather the artifacts matching it. * `cifmw_shiftstack_installation_dir`: (*string*) Directory to place installation files. Defaults to `"{{ cifmw_shiftstack_shiftstackclient_artifacts_dir }}/installation"`. * `cifmw_shiftstack_manifests_dir`: (*string*) Directory name for the role generated Openshift manifests. Defaults to `"{{ cifmw_shiftstack_basedir }}/manifests"`. * `cifmw_shiftstack_project_name`: (*string*) The Openstack project name. Defaults to `shiftstack`. diff --git a/roles/shiftstack/defaults/main.yml b/roles/shiftstack/defaults/main.yml index 4835e89d00..18a170a0fd 100644 --- a/roles/shiftstack/defaults/main.yml +++ b/roles/shiftstack/defaults/main.yml @@ -28,6 +28,7 @@ cifmw_shiftstack_client_pod_name: "shiftstackclient-{{ cifmw_shiftstack_project_ cifmw_shiftstack_client_pod_namespace: "openstack" cifmw_shiftstack_client_pvc_manifest: "{{ cifmw_shiftstack_client_pod_name }}_pvc.yml" cifmw_shiftstack_cluster_name: "ostest" +cifmw_shiftstack_exclude_artifacts_regex: "openshift-install" cifmw_shiftstack_installation_dir: "{{ cifmw_shiftstack_basedir }}/installation" cifmw_shiftstack_manifests_dir: "{{ cifmw_shiftstack_basedir }}/manifests" cifmw_shiftstack_project_name: "shiftstack" diff --git a/roles/shiftstack/molecule/default/converge.yml b/roles/shiftstack/molecule/default/converge.yml index ad49e1169d..fb30de5414 100644 --- a/roles/shiftstack/molecule/default/converge.yml +++ b/roles/shiftstack/molecule/default/converge.yml @@ -22,6 +22,7 @@ cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}" cifmw_openshift_kubeconfig: "{{ ansible_user_dir }}/.crc/machines/crc/kubeconfig" cifmw_shiftstack_run_playbook: cifmw-gate.yaml + cifmw_shiftstack_exclude_artifacts_regex: '' cifmw_run_test_shiftstack_testconfig: - cifmw-gate.yaml - cifmw-gate.yaml # The purpose of this repeated test config is to check the test config loop logic diff --git a/roles/shiftstack/tasks/pre_test_shiftstack.yml b/roles/shiftstack/tasks/pre_test_shiftstack.yml index 001ced3049..a285016b9a 100644 --- a/roles/shiftstack/tasks/pre_test_shiftstack.yml +++ b/roles/shiftstack/tasks/pre_test_shiftstack.yml @@ -21,6 +21,7 @@ - name: Remove the shiftstackclient pod if exists kubernetes.core.k8s: + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" state: absent api_version: v1 kind: Pod diff --git a/roles/shiftstack/tasks/test_config.yml b/roles/shiftstack/tasks/test_config.yml index c6d697d32d..861b85b195 100644 --- a/roles/shiftstack/tasks/test_config.yml +++ b/roles/shiftstack/tasks/test_config.yml @@ -31,6 +31,7 @@ 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 }} -e ocp_cluster_name={{ cifmw_shiftstack_cluster_name }} -e user_cloud={{ cifmw_shiftstack_project_name }} ansible.builtin.include_tasks: exec_command_in_pod.yml @@ -48,12 +49,19 @@ 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 }} + 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