|
30 | 30 | msg: "No kustomization.yaml file found in {{ app_dir }}. Documentation available at https://github.com/RS-PYTHON/rs-infra-core/blob/develop/docs/installation.md" |
31 | 31 | when: not kustomization_file.stat.exists |
32 | 32 |
|
33 | | - - name: "{{ package_name }} - {{ app_name }} | Include vars from kustomization.yaml" |
| 33 | + - name: "{{ package_name }} - {{ app_name }} | Include vars from {{ kustomization_file.stat.path }}" |
34 | 34 | include_vars: |
35 | | - file: "{{ app_dir }}/kustomization.yaml" |
| 35 | + file: "{{ kustomization_file.stat.path }}" |
36 | 36 | name: kustomization |
37 | 37 | delegate_to: bastion |
38 | 38 |
|
|
124 | 124 | {% endif %} \ |
125 | 125 | --server-side \ |
126 | 126 | --force-conflicts \ |
| 127 | + -o yaml \ |
127 | 128 | -l app.kubernetes.io/instance={{ app_name }} |
128 | 129 | register: result |
129 | 130 | delegate_to: bastion |
|
142 | 143 |
|
143 | 144 | - name: "{{ package_name }} - {{ app_name }} | Extract deployed resources" |
144 | 145 | set_fact: |
145 | | - resources: "{{ resources|d([]) + [item.split()[0]] }}" |
146 | | - loop: "{{ result.stdout_lines }}" |
| 146 | + # cleanup the yaml to fix invalid CRD definitions before parsing |
| 147 | + resources: >- |
| 148 | + {{ |
| 149 | + result.stdout |
| 150 | + | regex_replace('(?m)^([ ]*)- =$' , '\1- "="') |
| 151 | + | regex_replace('(?m)^([ ]*)- =~$', '\1- "=~"') |
| 152 | + | from_yaml_all |
| 153 | + | list |
| 154 | + }} |
147 | 155 | delegate_to: bastion |
148 | 156 |
|
149 | 157 | - name: "{{ package_name }} - {{ app_name }} | Collect deployed resources and write them into resources.txt" |
150 | 158 | copy: |
151 | | - content: "{{ resources | join(' ') }}" |
| 159 | + content: "{{ resources }}" |
152 | 160 | dest: "{{ app_dir }}/resources.txt" |
153 | 161 | delegate_to: bastion |
154 | 162 |
|
| 163 | + - name: "{{ package_name }} - {{ app_name }} | Wait for deployed resources readiness (when asked)" |
| 164 | + include_tasks: wait_ready.yaml |
| 165 | + args: |
| 166 | + apply: |
| 167 | + delegate_to: bastion |
| 168 | + # kubectl apply -o yaml does not produce the exact same output when applying one resource or several ones |
| 169 | + # make sure our resources list handles all cases |
| 170 | + loop: >- |
| 171 | + {{ |
| 172 | + resources |
| 173 | + | map('community.general.json_query', "items || [@]") |
| 174 | + | flatten |
| 175 | + | list |
| 176 | + }} |
| 177 | + loop_control: |
| 178 | + label: "{{ item.kind }}/{{ item.metadata.name }}" |
| 179 | + |
155 | 180 | - name: "{{ package_name }} - {{ app_name }} | Detect jobs for this app" |
156 | 181 | kubernetes.core.k8s_info: |
157 | 182 | kind: Job |
|
214 | 239 | delegate_to: bastion |
215 | 240 |
|
216 | 241 | rescue: |
| 242 | + - name: "{{ package_name }} - {{ app_name }} | Show resources" |
| 243 | + debug: |
| 244 | + var: resources |
| 245 | + when: resources | length > 0 |
| 246 | + |
217 | 247 | - name: "{{ package_name }} - {{ app_name }} | Show jobs status" |
218 | 248 | debug: |
219 | 249 | var: jobs.resources |
|
0 commit comments