feat: push template from CI
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Peter 2023-06-15 18:01:53 +02:00
parent 1fcab667ed
commit e1c9b6bb21
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
4 changed files with 50 additions and 5 deletions

39
.drone.yml Normal file
View file

@ -0,0 +1,39 @@
---
kind: pipeline
type: docker
name: default
trigger:
event:
- push
- pull_request
- tag
steps:
- name: Lint
image: docker.io/hashicorp/terraform
commands:
- cd hetzner-cloud/
- terraform init
- terraform validate
- name: Push
image: ghcr.io/coder/coder:v0.24.1
commands:
- |
coder templates push \
--name "$DRONE_COMMIT" \
--directory "hetzner-cloud" \
--variable hcloud_token="$HCLOUD_TOKEN" \
--variable use_subdomain=true \
--variable private_network_id="$HCLOUD_PRIVATE_NETWORK_ID" \
--yes \
"Hetzner-Cloud"
environment:
CODER_URL: https://ide.icb4dc0.de
CODER_SESSION_TOKEN:
from_secret: coder_token
HCLOUD_TOKEN:
from_secret: hcloud_token
HCLOUD_PRIVATE_NETWORK_ID:
from_secret: hcloud_private_network_id

2
.gitignore vendored
View file

@ -1 +1,3 @@
*.tar *.tar
.terraform/
*.lock.hcl

View file

@ -252,13 +252,13 @@ resource "tls_private_key" "rsa_4096" {
} }
resource "hcloud_ssh_key" "root" { resource "hcloud_ssh_key" "root" {
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root" name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
public_key = tls_private_key.rsa_4096.public_key_openssh public_key = tls_private_key.rsa_4096.public_key_openssh
} }
resource "hcloud_server" "root" { resource "hcloud_server" "root" {
count = data.coder_workspace.me.start_count count = data.coder_workspace.me.start_count
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root" name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
server_type = data.coder_parameter.instance_type.value server_type = data.coder_parameter.instance_type.value
location = data.coder_parameter.instance_location.value location = data.coder_parameter.instance_location.value
image = data.coder_parameter.instance_os.value image = data.coder_parameter.instance_os.value
@ -289,10 +289,14 @@ resource "hcloud_server" "root" {
} }
resource "hcloud_volume" "root" { resource "hcloud_volume" "root" {
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root" name = "coder-${data.coder_workspace.me.id}-home"
size = data.coder_parameter.volume_size.value size = data.coder_parameter.volume_size.value
format = "ext4" format = "ext4"
location = data.coder_parameter.instance_location.value location = data.coder_parameter.instance_location.value
lifecycle {
ignore_changes = all
}
} }
resource "hcloud_volume_attachment" "root" { resource "hcloud_volume_attachment" "root" {
@ -303,7 +307,7 @@ resource "hcloud_volume_attachment" "root" {
} }
resource "hcloud_firewall" "root" { resource "hcloud_firewall" "root" {
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root" name = "coder-${data.coder_workspace.me.owner_id}-${data.coder_workspace.me.id}-root"
rule { rule {
direction = "in" direction = "in"
protocol = "icmp" protocol = "icmp"