2024-04-02 17:15:40 +00:00
|
|
|
---
|
|
|
|
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
|
2024-04-06 17:56:56 +00:00
|
|
|
- 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"
|
2024-04-02 17:15:40 +00:00
|
|
|
- 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
|
|
|
|
workspaces:
|
|
|
|
- name: outputs
|
|
|
|
description: A folder to store outputs
|
|
|
|
optional: false
|
|
|
|
mountPath: /tmp/outputs
|