|
| 1 | +--- |
| 2 | +- name: Deploy Cyborg service |
| 3 | + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" |
| 4 | + gather_facts: false |
| 5 | + environment: |
| 6 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 7 | + PATH: "{{ cifmw_path }}" |
| 8 | + tasks: |
| 9 | + # NOTE(amoralej): Cyborg controllers and webhooks in the nova-operator |
| 10 | + # are gated behind the ENABLE_CYBORG=true env var (cmd/main.go). |
| 11 | + # The nova-operator deployment is owned and reconciled by the |
| 12 | + # openstack-operator, which rebuilds its env vars from scratch on |
| 13 | + # every reconcile loop (it Owns the Deployment). The OpenStack CRD |
| 14 | + # does not expose a way to inject custom env vars into sub-operator |
| 15 | + # deployments, so we must: |
| 16 | + # 1. Scale down the openstack-operator via its CSV to stop it |
| 17 | + # from reconciling (OLM manages the deployment, so we patch |
| 18 | + # the CSV replicas rather than scaling the deployment directly). |
| 19 | + # 2. Patch the nova-operator deployment directly to add ENABLE_CYBORG. |
| 20 | + # 3. Wait for the nova-operator to roll out with Cyborg enabled. |
| 21 | + - name: Get the openstack-operator CSV name |
| 22 | + ansible.builtin.command: |
| 23 | + cmd: >- |
| 24 | + oc get csv -n openstack-operators |
| 25 | + -l operators.coreos.com/openstack-operator.openstack-operators |
| 26 | + -o name |
| 27 | + register: csv_name |
| 28 | + |
| 29 | + - name: Patch CSV to scale down openstack-operator |
| 30 | + ansible.builtin.shell: | |
| 31 | + oc patch -n openstack-operators {{ csv_name.stdout }} --type json -p='[ |
| 32 | + {"op": "replace", |
| 33 | + "path": "/spec/install/spec/deployments/0/spec/replicas", |
| 34 | + "value": 0} |
| 35 | + ]' |
| 36 | +
|
| 37 | + - name: Wait for openstack-operator to scale down |
| 38 | + ansible.builtin.command: |
| 39 | + cmd: >- |
| 40 | + oc rollout status deployment/openstack-operator-controller-init |
| 41 | + -n openstack-operators --timeout=120s |
| 42 | +
|
| 43 | + - name: Patch nova-operator deployment to enable Cyborg |
| 44 | + ansible.builtin.command: |
| 45 | + cmd: >- |
| 46 | + oc set env deployment/nova-operator-controller-manager |
| 47 | + -n openstack-operators ENABLE_CYBORG=true |
| 48 | +
|
| 49 | + - name: Wait for nova-operator rollout |
| 50 | + ansible.builtin.command: |
| 51 | + cmd: >- |
| 52 | + oc rollout status deployment/nova-operator-controller-manager |
| 53 | + -n openstack-operators --timeout=300s |
| 54 | +
|
| 55 | + - name: Add CyborgPassword to osp-secret |
| 56 | + ansible.builtin.shell: | |
| 57 | + oc patch secret osp-secret \ |
| 58 | + --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} \ |
| 59 | + --type merge -p '{"data":{"CyborgPassword":"'"$(oc get secret osp-secret --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} -o jsonpath='{.data.AdminPassword}')"'"}}' |
| 60 | +
|
| 61 | + - name: Create Cyborg TLS certificates |
| 62 | + ansible.builtin.shell: | |
| 63 | + oc apply -f - <<EOF |
| 64 | + apiVersion: cert-manager.io/v1 |
| 65 | + kind: Certificate |
| 66 | + metadata: |
| 67 | + name: cyborg-internal-svc |
| 68 | + namespace: {{ cifmw_install_yamls_defaults['NAMESPACE'] }} |
| 69 | + spec: |
| 70 | + dnsNames: |
| 71 | + - cyborg-internal.{{ cifmw_install_yamls_defaults['NAMESPACE'] }}.svc |
| 72 | + - cyborg-internal.{{ cifmw_install_yamls_defaults['NAMESPACE'] }}.svc.cluster.local |
| 73 | + duration: 43800h0m0s |
| 74 | + issuerRef: |
| 75 | + group: cert-manager.io |
| 76 | + kind: Issuer |
| 77 | + name: rootca-internal |
| 78 | + secretName: cert-cyborg-internal-svc |
| 79 | + usages: |
| 80 | + - key encipherment |
| 81 | + - digital signature |
| 82 | + - server auth |
| 83 | + --- |
| 84 | + apiVersion: cert-manager.io/v1 |
| 85 | + kind: Certificate |
| 86 | + metadata: |
| 87 | + name: cyborg-public-svc |
| 88 | + namespace: {{ cifmw_install_yamls_defaults['NAMESPACE'] }} |
| 89 | + spec: |
| 90 | + dnsNames: |
| 91 | + - cyborg-public.{{ cifmw_install_yamls_defaults['NAMESPACE'] }}.svc |
| 92 | + - cyborg-public.{{ cifmw_install_yamls_defaults['NAMESPACE'] }}.svc.cluster.local |
| 93 | + duration: 43800h0m0s |
| 94 | + issuerRef: |
| 95 | + group: cert-manager.io |
| 96 | + kind: Issuer |
| 97 | + name: rootca-public |
| 98 | + secretName: cert-cyborg-public-svc |
| 99 | + usages: |
| 100 | + - key encipherment |
| 101 | + - digital signature |
| 102 | + - server auth |
| 103 | + EOF |
| 104 | +
|
| 105 | + - name: Wait for Cyborg certificate secrets to be created |
| 106 | + ansible.builtin.command: |
| 107 | + cmd: >- |
| 108 | + oc wait certificate {{ item }} |
| 109 | + --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} |
| 110 | + --for=condition=Ready --timeout=300s |
| 111 | + loop: |
| 112 | + - cyborg-internal-svc |
| 113 | + - cyborg-public-svc |
| 114 | + |
| 115 | + - name: Create Cyborg CR |
| 116 | + ansible.builtin.shell: | |
| 117 | + oc apply -f - <<EOF |
| 118 | + apiVersion: cyborg.openstack.org/v1beta1 |
| 119 | + kind: Cyborg |
| 120 | + metadata: |
| 121 | + name: cyborg |
| 122 | + namespace: {{ cifmw_install_yamls_defaults['NAMESPACE'] }} |
| 123 | + spec: |
| 124 | + apiContainerImageURL: quay.io/amoralej/openstack-cyborg:master-latest |
| 125 | + conductorContainerImageURL: quay.io/amoralej/openstack-cyborg:master-latest |
| 126 | + agentContainerImageURL: quay.io/amoralej/openstack-cyborg-agent:master-latest |
| 127 | + secret: osp-secret |
| 128 | + messagingBus: |
| 129 | + cluster: rabbitmq |
| 130 | + apiServiceTemplate: |
| 131 | + tls: |
| 132 | + caBundleSecretName: combined-ca-bundle |
| 133 | + api: |
| 134 | + internal: |
| 135 | + secretName: cert-cyborg-internal-svc |
| 136 | + public: |
| 137 | + secretName: cert-cyborg-public-svc |
| 138 | + EOF |
| 139 | +
|
| 140 | + - name: Wait for Cyborg CR to be ready |
| 141 | + ansible.builtin.command: |
| 142 | + cmd: >- |
| 143 | + oc wait cyborg cyborg |
| 144 | + --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} |
| 145 | + --for=condition=Ready --timeout=600s |
| 146 | +
|
| 147 | + - name: Create OpenStackDataPlaneService for cyborg |
| 148 | + ansible.builtin.shell: | |
| 149 | + oc apply -f - <<EOF |
| 150 | + apiVersion: dataplane.openstack.org/v1beta1 |
| 151 | + kind: OpenStackDataPlaneService |
| 152 | + metadata: |
| 153 | + name: cyborg |
| 154 | + namespace: {{ cifmw_install_yamls_defaults['NAMESPACE'] }} |
| 155 | + spec: |
| 156 | + dataSources: |
| 157 | + - secretRef: |
| 158 | + name: cyborg-agent-config |
| 159 | + - configMapRef: |
| 160 | + name: cyborg-extra-config |
| 161 | + optional: true |
| 162 | + playbook: osp.edpm.cyborg |
| 163 | + caCerts: combined-ca-bundle |
| 164 | + edpmServiceType: cyborg |
| 165 | + EOF |
0 commit comments