|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +--- |
| 5 | +- name: Stage PostgreSQL for the HA gateway |
| 6 | + hosts: all |
| 7 | + become: true |
| 8 | + gather_facts: false |
| 9 | + tasks: |
| 10 | + - name: Wait for SSH |
| 11 | + ansible.builtin.wait_for_connection: |
| 12 | + |
| 13 | + # The install layer boots fresh, so the K3s API may still be starting. |
| 14 | + - name: Apply OpenShell namespace |
| 15 | + ansible.builtin.command: |
| 16 | + argv: [/usr/local/bin/k3s, kubectl, apply, --filename, "-"] |
| 17 | + stdin: | |
| 18 | + apiVersion: v1 |
| 19 | + kind: Namespace |
| 20 | + metadata: |
| 21 | + name: openshell |
| 22 | + register: k3s_namespace |
| 23 | + until: k3s_namespace.rc == 0 |
| 24 | + retries: 30 |
| 25 | + delay: 2 |
| 26 | + |
| 27 | + - name: Apply PostgreSQL fixture |
| 28 | + ansible.builtin.command: |
| 29 | + argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, apply, --filename, "-"] |
| 30 | + stdin: "{{ lookup('ansible.builtin.file', openshell_postgres_fixture) }}" |
| 31 | + |
| 32 | + # Gateway Pods that start before the database crash-loop with growing backoff. |
| 33 | + - name: Wait for PostgreSQL |
| 34 | + ansible.builtin.command: |
| 35 | + argv: |
| 36 | + - /usr/local/bin/k3s |
| 37 | + - kubectl |
| 38 | + - --namespace |
| 39 | + - openshell |
| 40 | + - rollout |
| 41 | + - status |
| 42 | + - deployment/openshell-e2e-postgres |
| 43 | + - --timeout=300s |
| 44 | + changed_when: false |
| 45 | + |
| 46 | +- import_playbook: openshell-k3s.yaml |
| 47 | + vars: |
| 48 | + openshell_k3s_helm_values_overlay: | |
| 49 | + replicaCount: 3 |
| 50 | + workload: |
| 51 | + kind: deployment |
| 52 | + server: |
| 53 | + externalDbSecret: openshell-e2e-postgres-credentials |
| 54 | + disableTls: false |
| 55 | +
|
| 56 | +- name: Register the HA gateway over mTLS |
| 57 | + hosts: all |
| 58 | + become: true |
| 59 | + gather_facts: false |
| 60 | + tasks: |
| 61 | + # The chart's server certificate covers the Service DNS name but not its |
| 62 | + # ClusterIP, and the node resolver cannot reach cluster DNS. |
| 63 | + - name: Resolve the gateway Service name to its ClusterIP |
| 64 | + ansible.builtin.lineinfile: |
| 65 | + path: /etc/hosts |
| 66 | + regexp: '\sopenshell\.openshell\.svc\.cluster\.local$' |
| 67 | + line: "{{ k3s_gateway_address.stdout.split(':')[0] }} openshell.openshell.svc.cluster.local" |
| 68 | + |
| 69 | + - name: Read chart client TLS Secret |
| 70 | + ansible.builtin.command: |
| 71 | + argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, get, secret, openshell-client-tls, --output, json] |
| 72 | + register: k3s_client_tls |
| 73 | + changed_when: false |
| 74 | + no_log: true |
| 75 | + |
| 76 | + - name: Create guest mTLS directory |
| 77 | + ansible.builtin.file: |
| 78 | + path: /home/tmachine/.config/openshell/gateways/tmachine/mtls |
| 79 | + state: directory |
| 80 | + owner: tmachine |
| 81 | + group: tmachine |
| 82 | + mode: "0700" |
| 83 | + |
| 84 | + - name: Write guest client TLS bundle |
| 85 | + ansible.builtin.copy: |
| 86 | + content: "{{ (k3s_client_tls.stdout | from_json).data[item] | b64decode }}" |
| 87 | + dest: "/home/tmachine/.config/openshell/gateways/tmachine/mtls/{{ item }}" |
| 88 | + owner: tmachine |
| 89 | + group: tmachine |
| 90 | + mode: "0600" |
| 91 | + loop: [ca.crt, tls.crt, tls.key] |
| 92 | + no_log: true |
| 93 | + |
| 94 | + # The base playbook registered a plaintext endpoint; replace it. |
| 95 | + - name: Remove baseline guest gateway registration |
| 96 | + become: false |
| 97 | + ansible.builtin.command: |
| 98 | + argv: [/usr/local/bin/openshell, gateway, remove, tmachine] |
| 99 | + |
| 100 | + - name: Register guest gateway |
| 101 | + ansible.builtin.include_role: |
| 102 | + name: openshell_client |
| 103 | + apply: |
| 104 | + become: false |
| 105 | + vars: |
| 106 | + openshell_client_gateway_endpoint: "https://openshell.openshell.svc.cluster.local:{{ k3s_gateway_address.stdout.split(':')[1] }}" |
0 commit comments