|
1 | 1 | --- |
| 2 | +- name: Convert the pod info into a dict |
| 3 | + ansible.builtin.set_fact: |
| 4 | + pod: |
| 5 | + name: "{{ item.name if \"name\" in item else item }}" |
| 6 | + nspace: "{{ item.nspace if \"nspace\" in item else common_pod_nspace }}" |
| 7 | + status_str: "{{ item.status_str if \"status_str\" in item else common_pod_status_str }}" |
| 8 | + test_id: "{{ item.test_id if \"test_id\" in item else common_pod_test_id | default(omit) }}" |
| 9 | + |
| 10 | +- debug: var=pod |
| 11 | + |
2 | 12 | - block: |
3 | 13 | # expects that one line will be returned |
4 | 14 | # todo: define what happens when there are multiple pods returned |
5 | | - - name: Get Pod Instance name "{{ common_pod_status_str }}" |
| 15 | + - name: Get Pod Instance name "{{ pod.status_str }}" |
6 | 16 | ansible.builtin.shell: |
7 | 17 | cmd: | |
8 | | - oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" | grep "{{ common_pod_status_str }}" | awk '{print $1;}' |
| 18 | + oc get pods -n "{{ pod.nspace }}" | grep "{{ pod.name }}" | grep "{{ pod.status_str }}" | awk '{print $1;}' |
9 | 19 | register: podinstance |
10 | 20 | failed_when: |
11 | 21 | - podinstance.stdout_lines | length != 1 |
12 | 22 | changed_when: false |
13 | 23 |
|
14 | 24 | - name: | |
15 | | - TEST Check {{ item }} pod is {{ common_pod_status_str }} in {{ common_pod_nspace }} namespace |
16 | | - {{ common_pod_test_id }} |
| 25 | + TEST Check {{ pod.name }} pod is {{ pod.status_str }} in {{ pod.nspace }} namespace |
| 26 | + {{ pod.test_id if pod.test_id is defined }} |
17 | 27 | ansible.builtin.command: |
18 | 28 | cmd: | |
19 | | - oc get pod -n "{{ common_pod_nspace }}" "{{ podinstance.stdout }}" |
| 29 | + oc get pod -n "{{ pod.nspace }}" "{{ podinstance.stdout }}" |
20 | 30 | register: output |
21 | 31 | changed_when: false |
22 | 32 | failed_when: |
23 | 33 | - output.rc != 0 |
24 | 34 | - podinstance.stdout == "" |
25 | 35 | rescue: |
26 | | - - name: Get Pod Instance "{{ item }}" |
| 36 | + - name: Get Pod Instance "{{ pod.name }}" |
27 | 37 | ansible.builtin.shell: |
28 | 38 | cmd: | |
29 | | - oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" |
| 39 | + oc get pods -n "{{ pod.nspace }}" | grep "{{ pod.name }}" |
30 | 40 | register: podinstance |
31 | 41 | failed_when: |
32 | 42 | - podinstance.stdout_lines | length == 0 |
|
0 commit comments