|
52 | 52 | when: |
53 | 53 | - installation_mode == "upgrade" |
54 | 54 | - hasura_admin_secret_file.stat.exists |
55 | | - - api_use_existing_hasura_on_upgrade | default(false) | bool |
56 | 55 |
|
57 | | -- name: set hasura admin secret from existing file |
| 56 | +- name: cache existing hasura admin secret during upgrade |
58 | 57 | set_fact: |
59 | | - api_hasura_admin_secret: "{{ existing_hasura_admin_secret['content'] | b64decode | trim }}" |
| 58 | + api_existing_hasura_admin_secret: "{{ existing_hasura_admin_secret['content'] | b64decode | trim }}" |
60 | 59 | when: |
61 | 60 | - installation_mode == "upgrade" |
62 | 61 | - hasura_admin_secret_file.stat.exists |
| 62 | + |
| 63 | +- name: set hasura admin secret from existing file |
| 64 | + set_fact: |
| 65 | + api_hasura_admin_secret: "{{ api_existing_hasura_admin_secret }}" |
| 66 | + when: |
| 67 | + - installation_mode == "upgrade" |
63 | 68 | - api_use_existing_hasura_on_upgrade | default(false) | bool |
| 69 | + - api_existing_hasura_admin_secret is defined |
64 | 70 |
|
65 | 71 | - name: set static hasura admin pwd for test purposes only |
66 | 72 | set_fact: |
|
76 | 82 | when: |
77 | 83 | - api_hasura_admin_secret is not defined |
78 | 84 |
|
79 | | -- name: write hasura admin password to secrets directory |
80 | | - copy: |
81 | | - content: "{{ api_hasura_admin_secret }}\n" |
82 | | - dest: "{{ fworch_secrets_dir }}/hasura_admin_pwd" |
83 | | - mode: "0600" |
84 | | - owner: "{{ fworch_user }}" |
85 | | - group: "{{ fworch_group }}" |
86 | | - become: true |
87 | | - when: |
88 | | - - installation_mode != "upgrade" or not (api_use_existing_hasura_on_upgrade | default(false) | bool) or not hasura_admin_secret_file.stat.exists |
89 | | - |
90 | 85 | - name: check for existing hasura cli file |
91 | 86 | stat: |
92 | 87 | path: "{{ api_hasura_cli_bin }}" |
|
98 | 93 | {{ |
99 | 94 | installation_mode == "upgrade" |
100 | 95 | and (api_existing_service_name | default('') | length > 0) |
| 96 | + and hasura_admin_secret_file.stat.exists |
101 | 97 | }} |
102 | 98 |
|
| 99 | +- name: fail when Hasura upgrade reuse was requested without reusable state |
| 100 | + fail: |
| 101 | + msg: >- |
| 102 | + Hasura upgrade fallback requires both an installed Hasura service unit and the existing |
| 103 | + {{ fworch_secrets_dir }}/hasura_admin_pwd secret file. |
| 104 | + when: |
| 105 | + - installation_mode == "upgrade" |
| 106 | + - api_use_existing_hasura_on_upgrade | default(false) | bool |
| 107 | + - not api_hasura_upgrade_reuse_possible | bool |
| 108 | + |
103 | 109 | - name: build GitHub auth header |
104 | 110 | set_fact: |
105 | 111 | api_github_auth_header: "{{ {'Authorization': 'Bearer ' ~ api_github_token} if api_github_token is defined else {} }}" |
|
177 | 183 | - name: fall back to existing Hasura after CLI download failure during upgrade |
178 | 184 | set_fact: |
179 | 185 | api_use_existing_hasura_on_upgrade: true |
| 186 | + api_service_name: "{{ api_existing_service_name }}" |
| 187 | + api_hasura_admin_secret: "{{ api_existing_hasura_admin_secret }}" |
180 | 188 | when: api_hasura_upgrade_reuse_possible | bool |
181 | 189 |
|
182 | 190 | - name: show Hasura CLI upgrade fallback decision |
|
217 | 225 | - name: fall back to existing Hasura after direct CLI download failure during upgrade |
218 | 226 | set_fact: |
219 | 227 | api_use_existing_hasura_on_upgrade: true |
| 228 | + api_service_name: "{{ api_existing_service_name }}" |
| 229 | + api_hasura_admin_secret: "{{ api_existing_hasura_admin_secret }}" |
220 | 230 | when: api_hasura_upgrade_reuse_possible | bool |
221 | 231 |
|
222 | 232 | - name: show Hasura direct CLI upgrade fallback decision |
|
249 | 259 | - not api_cli_check.stat.exists |
250 | 260 | - not api_use_existing_hasura_on_upgrade | default(false) | bool |
251 | 261 |
|
252 | | -- name: set hasura env variable |
253 | | - set_fact: |
254 | | - hasura_env: |
255 | | - HASURA_GRAPHQL_DATABASE_URL: "postgres://{{ api_user }}:{{ api_user_password }}@{{ fworch_db_host }}:{{ fworch_db_port }}/{{ fworch_db_name }}" |
256 | | - HASURA_GRAPHQL_ENABLE_CONSOLE: "true" |
257 | | - HASURA_GRAPHQL_ENABLE_TELEMETRY: "false" |
258 | | - HASURA_GRAPHQL_ADMIN_SECRET: "{{ api_hasura_admin_secret }}" |
259 | | - HASURA_GRAPHQL_SERVER_HOST: "127.0.0.1" |
260 | | - HASURA_GRAPHQL_SERVER_PORT: "8080" |
261 | | - HASURA_GRAPHQL_LOG_LEVEL: "{{ api_log_level }}" |
262 | | - HASURA_GRAPHQL_ENABLED_LOG_TYPES: "{{ api_HASURA_GRAPHQL_ENABLED_LOG_TYPES }}" |
263 | | - HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: "/srv/console-assets" |
264 | | - HASURA_GRAPHQL_V1_BOOLEAN_NULL_COLLAPSE: "true" |
265 | | - HASURA_GRAPHQL_CORS_DOMAIN: "*" |
266 | | - HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS: "{{ api_HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS }}" |
267 | | - HASURA_GRAPHQL_JWT_SECRET: "{{ {'type': api_hasura_jwt_alg, 'key': api_hasura_jwt_secret | regex_replace('\n', '\\n'), 'claims_namespace_path': '$'} | to_json }}" |
268 | | - HTTP_PROXY: "{{ http_proxy }}" |
269 | | - HTTPS_PROXY: "{{ https_proxy }}" |
270 | | - http_proxy: "{{ http_proxy }}" |
271 | | - https_proxy: "{{ https_proxy }}" |
272 | | - no_proxy: "{{ no_proxy }}" |
273 | | - NO_PROXY: "{{ no_proxy }}" |
274 | | - |
275 | | -- name: show hasura env for debugging |
276 | | - debug: |
277 | | - var: hasura_env |
278 | | - when: debug_level > '1' |
279 | | - |
280 | 262 | - name: set Hasura image reuse mode |
281 | 263 | set_fact: |
282 | 264 | api_reuse_existing_hasura_image: >- |
|
307 | 289 | set_fact: |
308 | 290 | api_use_existing_hasura_on_upgrade: true |
309 | 291 | api_reuse_existing_hasura_image: true |
| 292 | + api_service_name: "{{ api_existing_service_name }}" |
| 293 | + api_hasura_admin_secret: "{{ api_existing_hasura_admin_secret }}" |
310 | 294 | when: api_hasura_upgrade_reuse_possible | bool |
311 | 295 |
|
312 | 296 | - name: show Hasura image upgrade fallback decision |
|
327 | 311 | - not api_reuse_existing_hasura_image | bool |
328 | 312 | - api_rollback_is_running | default(false) | bool == false |
329 | 313 |
|
| 314 | +- name: write hasura admin password to secrets directory |
| 315 | + copy: |
| 316 | + content: "{{ api_hasura_admin_secret }}\n" |
| 317 | + dest: "{{ fworch_secrets_dir }}/hasura_admin_pwd" |
| 318 | + mode: "0600" |
| 319 | + owner: "{{ fworch_user }}" |
| 320 | + group: "{{ fworch_group }}" |
| 321 | + become: true |
| 322 | + when: |
| 323 | + - installation_mode != "upgrade" or not (api_use_existing_hasura_on_upgrade | default(false) | bool) or not hasura_admin_secret_file.stat.exists |
| 324 | + |
| 325 | +- name: set hasura env variable |
| 326 | + set_fact: |
| 327 | + hasura_env: |
| 328 | + HASURA_GRAPHQL_DATABASE_URL: "postgres://{{ api_user }}:{{ api_user_password }}@{{ fworch_db_host }}:{{ fworch_db_port }}/{{ fworch_db_name }}" |
| 329 | + HASURA_GRAPHQL_ENABLE_CONSOLE: "true" |
| 330 | + HASURA_GRAPHQL_ENABLE_TELEMETRY: "false" |
| 331 | + HASURA_GRAPHQL_ADMIN_SECRET: "{{ api_hasura_admin_secret }}" |
| 332 | + HASURA_GRAPHQL_SERVER_HOST: "127.0.0.1" |
| 333 | + HASURA_GRAPHQL_SERVER_PORT: "8080" |
| 334 | + HASURA_GRAPHQL_LOG_LEVEL: "{{ api_log_level }}" |
| 335 | + HASURA_GRAPHQL_ENABLED_LOG_TYPES: "{{ api_HASURA_GRAPHQL_ENABLED_LOG_TYPES }}" |
| 336 | + HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: "/srv/console-assets" |
| 337 | + HASURA_GRAPHQL_V1_BOOLEAN_NULL_COLLAPSE: "true" |
| 338 | + HASURA_GRAPHQL_CORS_DOMAIN: "*" |
| 339 | + HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS: "{{ api_HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS }}" |
| 340 | + HASURA_GRAPHQL_JWT_SECRET: "{{ {'type': api_hasura_jwt_alg, 'key': api_hasura_jwt_secret | regex_replace('\n', '\\n'), 'claims_namespace_path': '$'} | to_json }}" |
| 341 | + HTTP_PROXY: "{{ http_proxy }}" |
| 342 | + HTTPS_PROXY: "{{ https_proxy }}" |
| 343 | + http_proxy: "{{ http_proxy }}" |
| 344 | + https_proxy: "{{ https_proxy }}" |
| 345 | + no_proxy: "{{ no_proxy }}" |
| 346 | + NO_PROXY: "{{ no_proxy }}" |
| 347 | + |
| 348 | +- name: show hasura env for debugging |
| 349 | + debug: |
| 350 | + var: hasura_env |
| 351 | + when: debug_level > '1' |
| 352 | + |
330 | 353 | - name: write Hasura env file for Podman |
331 | 354 | copy: |
332 | 355 | dest: "{{ api_env_file }}" |
|
0 commit comments