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

86 lines
2.6 KiB
YAML
Raw Normal View History

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-05-08 15:38:52 +00:00
- 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
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: |-
2024-05-08 15:38:52 +00:00
#!/bin/bash
export $(grep -v '^#' /tmp/outputs/dotenv | xargs -0)
env
2024-04-02 17:15:40 +00:00
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
2024-05-04 16:42:28 +00:00
- 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
2024-04-02 17:15:40 +00:00
workspaces:
- name: outputs
description: A folder to store outputs
optional: false
mountPath: /tmp/outputs