|
| 1 | +--- |
| 2 | +- name: Install pattern (using pattern-install chart) |
| 3 | + hosts: localhost |
| 4 | + connection: local |
| 5 | + gather_facts: false |
| 6 | + |
| 7 | + roles: |
| 8 | + - role: pattern_settings # set general pattern vars |
| 9 | + - role: install_settings # set pattern-install specific vars |
| 10 | + - role: validate_prereq # ensure installation depencies are present |
| 11 | + - role: validate_cluster # ensure a cluster is connected and has a default storage class |
| 12 | + - role: pattern_install_template # render the pattern-install helm chart |
| 13 | + |
| 14 | + tasks: |
| 15 | + - name: Origin validation (optional, controlled by DISABLE_VALIDATE_ORIGIN / disable_validate_origin) |
| 16 | + block: |
| 17 | + - name: Resolve disable_validate_origin flag |
| 18 | + ansible.builtin.set_fact: |
| 19 | + disable_validate_origin: >- |
| 20 | + {{ |
| 21 | + ( |
| 22 | + disable_validate_origin |
| 23 | + | default(lookup('env', 'DISABLE_VALIDATE_ORIGIN'), true) |
| 24 | + | default('false', false) |
| 25 | + ) | bool |
| 26 | + }} |
| 27 | +
|
| 28 | + - name: Validate origin (remote/branch must exist) |
| 29 | + ansible.builtin.include_role: |
| 30 | + name: validate_origin |
| 31 | + when: not disable_validate_origin |
| 32 | + |
| 33 | + - name: Apply rendered pattern-install chart manifests (with retry) |
| 34 | + block: |
| 35 | + - name: Preview manifest that will be applied |
| 36 | + ansible.builtin.shell: | |
| 37 | + printf "==> Applying the following manifest to the cluster:\n\n" > /dev/tty |
| 38 | + printf "%s\n" "{{ pattern_install_rendered_yaml }}" > /dev/tty |
| 39 | +
|
| 40 | + - name: Apply via oc with retry |
| 41 | + ansible.builtin.command: oc apply -f - |
| 42 | + args: |
| 43 | + stdin: "{{ pattern_install_rendered_yaml }}" |
| 44 | + stdin_add_newline: false |
| 45 | + register: _apply |
| 46 | + retries: 10 |
| 47 | + delay: 15 |
| 48 | + until: _apply.rc == 0 |
| 49 | + |
| 50 | + - name: Print success message |
| 51 | + ansible.builtin.shell: printf "==> Installation succeeded!\n" > /dev/tty |
| 52 | + |
| 53 | + rescue: |
| 54 | + - name: Print failure summary and abort |
| 55 | + ansible.builtin.shell: | |
| 56 | + printf "==> Installation failed. Error:\n" > /dev/tty |
| 57 | + printf "%s\n" "{{ _apply.stderr | default(_apply.stdout) | default('') }}" > /dev/tty |
| 58 | + exit 1 |
0 commit comments