softplayer-helmfile/charts/tekton-pipelines/templates/tasks/prepare-hetzner-infra.yml

75 lines
2.3 KiB
YAML

---
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: 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/sh
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