|
| 1 | +- name: Reset volumes and volume_mounts to an empty list |
| 2 | + ansible.builtin.set_fact: |
| 3 | + volumes: [] |
| 4 | + volume_mounts: [] |
| 5 | + |
| 6 | +- name: Get information about PVCs that store the logs |
| 7 | + kubernetes.core.k8s_info: |
| 8 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 9 | + api_key: "{{ cifmw_openshift_token | default(omit)}}" |
| 10 | + context: "{{ cifmw_openshift_context | default(omit)}}" |
| 11 | + namespace: "{{ cifmw_test_operator_namespace }}" |
| 12 | + kind: PersistentVolumeClaim |
| 13 | + label_selectors: |
| 14 | + - "instanceName={{ test_operator_instance_name }}" |
| 15 | + register: logsPVCs |
| 16 | + |
| 17 | +- name: Set up volume mounts and volumes for all PVCs |
| 18 | + ansible.builtin.set_fact: |
| 19 | + volume_mounts: > |
| 20 | + {{ |
| 21 | + (volume_mounts | default([])) + [{ |
| 22 | + 'name': "logs-volume-" ~ index, |
| 23 | + 'mountPath': "/mnt/logs-{{ test_operator_instance_name }}-step-" ~ index |
| 24 | + }] |
| 25 | + }} |
| 26 | + volumes: > |
| 27 | + {{ |
| 28 | + (volumes | default([])) + [{ |
| 29 | + 'name': "logs-volume-" ~ index, |
| 30 | + 'persistentVolumeClaim': { |
| 31 | + 'claimName': pvc.metadata.name |
| 32 | + } |
| 33 | + }] |
| 34 | + }} |
| 35 | + loop: "{{ logsPVCs.resources }}" |
| 36 | + loop_control: |
| 37 | + loop_var: pvc |
| 38 | + index_var: index |
| 39 | + |
| 40 | +- name: Write log pod definition to file |
| 41 | + ansible.builtin.copy: |
| 42 | + content: "{{ cifmw_test_operator_log_pod_definition }}" |
| 43 | + dest: "{{ cifmw_test_operator_crs_path }}/{{ test_operator_instance_name }}-log-pod.yaml" |
| 44 | + mode: '0644' |
| 45 | + |
| 46 | +- name: Start test-operator-logs-pod |
| 47 | + kubernetes.core.k8s: |
| 48 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 49 | + api_key: "{{ cifmw_openshift_token | default(omit)}}" |
| 50 | + context: "{{ cifmw_openshift_context | default(omit)}}" |
| 51 | + state: present |
| 52 | + wait: true |
| 53 | + src: "{{ cifmw_test_operator_crs_path }}/{{ test_operator_instance_name }}-log-pod.yaml" |
| 54 | + |
| 55 | +- name: Ensure that the test-operator-logs-pod is Running |
| 56 | + kubernetes.core.k8s_info: |
| 57 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 58 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 59 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 60 | + namespace: "{{ cifmw_test_operator_namespace }}" |
| 61 | + kind: Pod |
| 62 | + name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}" |
| 63 | + wait: true |
| 64 | + register: logs_pod |
| 65 | + until: logs_pod.resources[0].status.phase == "Running" |
| 66 | + delay: 10 |
| 67 | + retries: 20 |
| 68 | + |
| 69 | +- name: Get logs from test-operator-logs-pod |
| 70 | + environment: |
| 71 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 72 | + PATH: "{{ cifmw_path }}" |
| 73 | + vars: |
| 74 | + pod_path: mnt/logs-{{ test_operator_instance_name }}-step-{{ index }} |
| 75 | + ansible.builtin.shell: > |
| 76 | + oc cp -n {{ cifmw_test_operator_namespace }} |
| 77 | + test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}:{{ pod_path }} |
| 78 | + {{ cifmw_test_operator_artifacts_basedir }} |
| 79 | + loop: "{{ logsPVCs.resources }}" |
| 80 | + loop_control: |
| 81 | + index_var: index |
0 commit comments