e2cb2eabba
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
103 lines
3.4 KiB
YAML
103 lines
3.4 KiB
YAML
id: hetzner-server-type-location-update
|
|
namespace: hetzner
|
|
|
|
triggers:
|
|
- id: every-15-minutes-daytime
|
|
type: io.kestra.plugin.core.trigger.Schedule
|
|
cron: "*/15 7-21 * * *"
|
|
timezone: Europe/Berlin
|
|
|
|
|
|
tasks:
|
|
- id: fetch_server_types
|
|
type: io.kestra.plugin.scripts.shell.Commands
|
|
containerImage: alpine:latest
|
|
env:
|
|
HCLOUD_TOKEN: "{{ secret('HCLOUD_TOKEN') }}"
|
|
beforeCommands:
|
|
- apk add --no-cache curl jq
|
|
commands:
|
|
- |
|
|
set -eo pipefail
|
|
|
|
curl -sS \
|
|
-H "Authorization: Bearer $HCLOUD_TOKEN" \
|
|
"https://api.hetzner.cloud/v1/server_types" \
|
|
| jq -c '
|
|
[
|
|
.server_types[]
|
|
| select(.name == "cx23" or .name == "cx33" or .name == "cpx42")
|
|
| {
|
|
name: .name,
|
|
description: .description,
|
|
cores: .cores,
|
|
memory: .memory,
|
|
disk: .disk,
|
|
locations: [
|
|
.prices[]
|
|
| select(.location == "nbg1" or .location == "fsn1" or .location == "hel1")
|
|
| .location
|
|
] | unique
|
|
}
|
|
]
|
|
' > hetzner-server-types.json
|
|
|
|
jq -c '
|
|
[
|
|
.[]
|
|
| .name as $type
|
|
| .locations[]
|
|
| "\($type)|\(.)"
|
|
]
|
|
' hetzner-server-types.json > hetzner-server-type-location-options.json
|
|
|
|
echo "Server-Type/Location Matrix:"
|
|
cat hetzner-server-types.json
|
|
|
|
echo "Dropdown-Optionen:"
|
|
cat hetzner-server-type-location-options.json
|
|
|
|
outputFiles:
|
|
- hetzner-server-types.json
|
|
- hetzner-server-type-location-options.json
|
|
|
|
- id: upload_to_minio
|
|
type: io.kestra.plugin.scripts.shell.Commands
|
|
containerImage: minio/mc:latest
|
|
env:
|
|
AWS_ACCESS_KEY_ID: "{{ secret('AWS_ACCESS_KEY_ID') }}"
|
|
AWS_SECRET_ACCESS_KEY: "{{ secret('AWS_SECRET_ACCESS_KEY') }}"
|
|
TF_BACKEND_BUCKET: "{{ secret('TF_BACKEND_BUCKET') }}"
|
|
TF_BACKEND_ENDPOINT: "{{ secret('TF_BACKEND_ENDPOINT') }}"
|
|
inputFiles:
|
|
hetzner-server-types.json: "{{ outputs.fetch_server_types.outputFiles['hetzner-server-types.json'] }}"
|
|
hetzner-server-type-location-options.json: "{{ outputs.fetch_server_types.outputFiles['hetzner-server-type-location-options.json'] }}"
|
|
commands:
|
|
- |
|
|
set -eo pipefail
|
|
|
|
mc alias set tfstate "$TF_BACKEND_ENDPOINT" "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY"
|
|
|
|
mc cp hetzner-server-types.json "tfstate/$TF_BACKEND_BUCKET/inventory/hetzner-server-types.json"
|
|
mc cp hetzner-server-type-location-options.json "tfstate/$TF_BACKEND_BUCKET/inventory/hetzner-server-type-location-options.json"
|
|
|
|
echo "Server-Type/Location-Liste wurde nach MinIO/S3 geschrieben."
|
|
|
|
- id: set_options_kv
|
|
type: io.kestra.plugin.core.kv.Set
|
|
key: hetzner_server_type_location_options
|
|
kvType: JSON
|
|
value: "{{ read(outputs.fetch_server_types.outputFiles['hetzner-server-type-location-options.json']) }}"
|
|
|
|
- id: log_result
|
|
type: io.kestra.plugin.core.log.Log
|
|
message: |
|
|
✅ Hetzner Server-Type/Location-Liste wurde aktualisiert.
|
|
|
|
MinIO/S3:
|
|
s3://{{ secret('TF_BACKEND_BUCKET') }}/inventory/hetzner-server-types.json
|
|
s3://{{ secret('TF_BACKEND_BUCKET') }}/inventory/hetzner-server-type-location-options.json
|
|
|
|
Kestra KV:
|
|
hetzner_server_type_location_options
|