--- apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: prepare-hetzner-infra namespace: {{ .Values.pipelineNamespace }} labels: {{- include "tekton-pipelines.labels" . | nindent 4 }} spec: params: - name: namespace type: string - name: environment type: string steps: - name: get-ssh-key image: alpine/k8s:1.29.2 script: |- #!/bin/sh kubectl get secret "$(params.environment)"-ssh \ --namespace "$(params.namespace)" -o yaml \ | yq '.data."ssh_key.pub"' \ | base64 -d > /tmp/outputs/ssh_key.pub chmod 0600 /tmp/outputs/ssh_key.pub - name: annonate-an-env-cm image: alpine/k8s:1.29.2 script: |- #!/bin/sh kubectl annotate --overwrite configmap \ "$(params.environment)" \ --namespace "$(params.namespace)" \ "softplayer.net/status=infra-bootstrapping" - name: get-dotenv-from-configmap image: alpine/k8s:1.29.2 script: |- #!/bin/sh kubectl get configmap -o yaml \ $(params.environment) \ --namespace "$(params.namespace)" \ | yq '.data.vars' > /tmp/outputs/dotenv - name: create-hetzner-infra image: git.badhouseplants.net/softplayer/softplayer-coskgne:latest env: - name: SP_STATE value: present - name: SP_ENV value: $(params.environment) - name: SP_CUSTOMER value: $(params.namespace) - name: SOPS_AGE_KEY value: {{ .Values.providers.hetzner.ageKey }} script: |- #!/bin/bash export $(grep -v '^#' /tmp/outputs/dotenv | xargs -0) env ansible-playbook /src/playbooks/providers/hetzner/playbook.yml - name: save-inventory image: alpine/k8s:1.29.2 script: |- #!/bin/sh kubectl delete secret \ "$(params.environment)"-inventory \ --namespace "$(params.namespace)" kubectl create secret generic \ "$(params.environment)"-inventory \ --namespace "$(params.namespace)" \ --from-file /tmp/outputs/inventory.yaml - name: save-provider-outputs image: alpine/k8s:1.29.2 script: |- #!/bin/sh kubectl delete configmap \ "$(params.environment)"-provider-outputs \ --namespace "$(params.namespace)" kubectl create configmap \ "$(params.environment)"-provider-outputs \ --namespace "$(params.namespace)" \ --from-file /tmp/outputs/provider_outputs.yaml workspaces: - name: outputs description: A folder to store outputs optional: false mountPath: /tmp/outputs