|
26 | 26 | loop_control: |
27 | 27 | loop_var: tobikoconf_section |
28 | 28 |
|
| 29 | +- name: Slurp tobiko.conf |
| 30 | + ansible.builtin.slurp: |
| 31 | + path: "{{ cifmw_test_operator_artifacts_basedir }}/tobiko.conf" |
| 32 | + register: tobikoconf_content |
| 33 | + |
29 | 34 | - name: Add config section to tobiko CR |
| 35 | + vars: |
| 36 | + tobikoconf_content_decoded: "{{ tobikoconf_content.content | b64decode }}" |
30 | 37 | ansible.builtin.set_fact: |
31 | 38 | test_operator_cr: >- |
32 | 39 | {{ |
33 | 40 | test_operator_cr | |
34 | | - combine({'spec': {'config': |
35 | | - lookup('file', |
36 | | - cifmw_test_operator_artifacts_basedir + '/tobiko.conf') |
37 | | - }}, recursive=true) |
| 41 | + combine({'spec': {'config': tobikoconf_content_decoded}}, recursive=true) |
38 | 42 | }} |
39 | 43 |
|
40 | 44 | - name: Add ssh keys used for the VMs that tobiko creates to tobiko CR |
|
51 | 55 | size: "{{ stage_vars_dict.cifmw_test_operator_tobiko_ssh_keysize }}" |
52 | 56 | when: not check_ssh_key.stat.exists |
53 | 57 |
|
| 58 | + - name: Slurp key files |
| 59 | + vars: |
| 60 | + keyfilename: "id_{{ stage_vars_dict.cifmw_test_operator_tobiko_ssh_keytype }}{{ '.pub' if item == 'public' else '' }}" |
| 61 | + ansible.builtin.slurp: |
| 62 | + path: "{{ cifmw_test_operator_artifacts_basedir }}/{{ keyfilename }}" |
| 63 | + register: key_file_content |
| 64 | + loop: |
| 65 | + - private |
| 66 | + - public |
| 67 | + |
54 | 68 | - name: Add private and public keys to tobiko CR |
55 | 69 | vars: |
56 | 70 | keyname: "{{ item }}Key" |
57 | | - keyfilename: "id_{{ stage_vars_dict.cifmw_test_operator_tobiko_ssh_keytype }}{{ '.pub' if item == 'public' else '' }}" |
58 | 71 | ansible.builtin.set_fact: |
59 | 72 | test_operator_cr: >- |
60 | 73 | {{ |
61 | 74 | test_operator_cr | |
62 | | - combine({'spec': {keyname: |
63 | | - lookup('file', |
64 | | - cifmw_test_operator_artifacts_basedir + '/' + keyfilename) |
65 | | - }}, recursive=true) |
| 75 | + combine({'spec': {keyname: key_file_content.results[idx].content | b64decode}}, recursive=true) |
66 | 76 | }} |
67 | | - with_items: |
| 77 | + loop: |
68 | 78 | - private |
69 | 79 | - public |
| 80 | + loop_control: |
| 81 | + index_var: idx |
70 | 82 |
|
71 | 83 | - name: Add preventCreate if it is defined |
72 | 84 | ansible.builtin.set_fact: |
|
88 | 100 | }} |
89 | 101 | when: stage_vars_dict.cifmw_test_operator_tobiko_num_processes is not none |
90 | 102 |
|
| 103 | +- name: Slurp kubeconfig file |
| 104 | + ansible.builtin.slurp: |
| 105 | + path: "{{ cifmw_openshift_kubeconfig }}" |
| 106 | + register: kubeconfig_file_content |
| 107 | + |
91 | 108 | - name: Ensure a secret for the kubeconfig file exists |
92 | 109 | kubernetes.core.k8s: |
93 | 110 | kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
|
103 | 120 | name: "{{ stage_vars_dict.cifmw_test_operator_tobiko_kubeconfig_secret }}" |
104 | 121 | namespace: "{{ stage_vars_dict.cifmw_test_operator_namespace }}" |
105 | 122 | data: |
106 | | - config: "{{ lookup('file', cifmw_openshift_kubeconfig) | b64encode }}" |
| 123 | + # b64decode not needed because the text has to be encoded |
| 124 | + config: "{{ kubeconfig_file_content.content }}" |
107 | 125 | when: not cifmw_test_operator_dry_run | bool |
0 commit comments