diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1cc088f --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +ignition: + $(MAKE) -C flatcar ignition + +plan: + terraform plan -var-file production.tfvars + +apply: + terraform apply -var-file production.tfvars + +testlocalhost: + curl -k --resolve localhost:443:146.190.12.129 https://localhost diff --git a/cl/machine-mynode.yaml.tmpl b/cl/machine-mynode.yaml.tmpl index 146d17a..e15f15d 100644 --- a/cl/machine-mynode.yaml.tmpl +++ b/cl/machine-mynode.yaml.tmpl @@ -15,4 +15,4 @@ storage: set -euo pipefail # This script demonstrates how templating and variable substitution works when using Terraform templates for Container Linux Configs. hostname="$(hostname)" - echo My name is ${name} and the hostname is $${hostname} and this is updated, again 4x! + echo My name is ${name} and the hostname is $${hostname} and this is updated, again 5x! diff --git a/flatcar-quickstart2/Makefile b/flatcar-quickstart2/Makefile deleted file mode 100644 index f675d00..0000000 --- a/flatcar-quickstart2/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -build: - cp --reflink=auto flatcar_production_qemu_image.img.fresh flatcar_production_qemu_image.img - cat cl.yaml | sudo docker run --rm --volume ${PWD}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json - -run: - ./flatcar_production_qemu.sh -i ignition.json diff --git a/flatcar-quickstart2/ignition.json b/flatcar-quickstart2/ignition.json deleted file mode 100644 index e9594d5..0000000 --- a/flatcar-quickstart2/ignition.json +++ /dev/null @@ -1 +0,0 @@ -{"ignition":{"version":"3.4.0"},"storage":{"files":[{"path":"/var/lb/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0A%23%20respond%20%22lb!%22%0Areverse_proxy%20http%3A%2F%2Fnginx%0Alog"}},{"path":"/var/thintz-com/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22thintz-com!%22%0Alog"}},{"path":"/opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw","contents":{"source":"https://extensions.flatcar.org/extensions/docker-compose-2.34.0-x86-64.raw"},"mode":420},{"path":"/etc/sysupdate.docker-compose.d/docker-compose.conf","contents":{"source":"https://extensions.flatcar.org/extensions/docker-compose.conf"}},{"path":"/etc/sysupdate.d/noop.conf","contents":{"source":"https://extensions.flatcar.org/extensions/noop.conf"}},{"group":{"name":"core"},"path":"/home/core/docker-compose.yaml","user":{"name":"core"},"contents":{"compression":"gzip","source":"data:;base64,H4sIAAAAAAAC/6yRz27DIAzG73kKqz30lCVqckB+m4RYHSrBkXHZn6efoJtKpEmTpnJA5vMPY38kkug4IJyGUxNJkrMUsQHwc94B3DpdCGFheyV5cdzZaVk+8FySif1tvfN5tdClSTo/f0Mdqb2HBQikbyzXCvdzCYWiTqIIt+ApxjYqbxstJbexaHXjMI4DjuNweCimR9Pns766oJ+t5fXfrT9KPG2EcHHhfddQUf4c/NenjpUlxx/d9KZ4slPOaPqmrpE/9CsAAP//c5WIAe4BAAA="},"mode":420}],"links":[{"path":"/etc/extensions/docker-compose.raw","hard":false,"target":"/opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw"}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=Main App\nAfter=docker.service\nRequires=docker.service\n[Service]\nTimeoutStartSec=0\nExecStart=/usr/bin/docker compose -f /home/core/docker-compose.yaml up\nExecStop=/usr/bin/docker compose -f /home/core/docker-compose.yaml stop\n\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target\n","enabled":true,"name":"app.service"},{"enabled":true,"name":"systemd-sysupdate.timer"},{"dropins":[{"contents":"[Service]\nExecStartPre=/usr/bin/sh -c \"readlink --canonicalize /etc/extensions/docker-compose.raw \u003e /tmp/docker-compose\"\nExecStartPre=/usr/lib/systemd/systemd-sysupdate -C docker-compose update\nExecStartPost=/usr/bin/sh -c \"readlink --canonicalize /etc/extensions/docker-compose.raw \u003e /tmp/docker-compose-new\"\nExecStartPost=/usr/bin/sh -c \"if ! cmp --silent /tmp/docker-compose /tmp/docker-compose-new; then touch /run/reboot-required; fi\"\n","name":"docker-compose.conf"}],"name":"systemd-sysupdate.service"}]}} diff --git a/flatcar/Makefile b/flatcar/Makefile new file mode 100644 index 0000000..5ef34ca --- /dev/null +++ b/flatcar/Makefile @@ -0,0 +1,12 @@ +# get the directory of this makefile +ROOT_DIR:=$(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") + +ignition: + cat cl.yaml | sudo docker run --rm --volume ${ROOT_DIR}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json + +build: + cp --reflink=auto flatcar_production_qemu_image.img.fresh flatcar_production_qemu_image.img + make ignition + +run: + ./flatcar_production_qemu.sh -i ignition.json diff --git a/flatcar-quickstart2/app/app.service b/flatcar/app/app.service similarity index 100% rename from flatcar-quickstart2/app/app.service rename to flatcar/app/app.service diff --git a/flatcar-quickstart2/app/docker-compose.yaml b/flatcar/app/docker-compose.yaml similarity index 100% rename from flatcar-quickstart2/app/docker-compose.yaml rename to flatcar/app/docker-compose.yaml diff --git a/flatcar-quickstart2/cl.yaml b/flatcar/cl.yaml similarity index 96% rename from flatcar-quickstart2/cl.yaml rename to flatcar/cl.yaml index 37b2739..af0be2c 100644 --- a/flatcar-quickstart2/cl.yaml +++ b/flatcar/cl.yaml @@ -1,5 +1,10 @@ variant: flatcar version: 1.1.0 +passwd: + users: + - name: core + ssh_authorized_keys: + - "" systemd: units: - name: app.service diff --git a/flatcar-quickstart2/docker-network/docker-network.service b/flatcar/docker-network/docker-network.service similarity index 100% rename from flatcar-quickstart2/docker-network/docker-network.service rename to flatcar/docker-network/docker-network.service diff --git a/flatcar-quickstart2/flatcar_production_qemu.sh b/flatcar/flatcar_production_qemu.sh similarity index 100% rename from flatcar-quickstart2/flatcar_production_qemu.sh rename to flatcar/flatcar_production_qemu.sh diff --git a/flatcar-quickstart2/lb/Caddyfile b/flatcar/lb/Caddyfile similarity index 100% rename from flatcar-quickstart2/lb/Caddyfile rename to flatcar/lb/Caddyfile diff --git a/flatcar-quickstart2/thintz-com/Caddyfile b/flatcar/thintz-com/Caddyfile similarity index 100% rename from flatcar-quickstart2/thintz-com/Caddyfile rename to flatcar/thintz-com/Caddyfile diff --git a/main.tf b/main.tf index 975a28e..225fb3c 100644 --- a/main.tf +++ b/main.tf @@ -78,7 +78,8 @@ resource "digitalocean_droplet" "machine" { region = var.datacenter size = var.server_type ssh_keys = [digitalocean_ssh_key.first.fingerprint] - user_data = data.ct_config.machine-ignitions[each.key].rendered + # user_data = data.ct_config.machine-ignitions[each.key].rendered + user_data = file("flatcar/ignition.json") lifecycle { create_before_destroy = true } @@ -90,14 +91,14 @@ resource "digitalocean_reserved_ip_assignment" "machine" { droplet_id = digitalocean_droplet.machine[each.key].id } -data "ct_config" "machine-ignitions" { - for_each = toset(var.machines) - content = templatefile("${path.module}/cl/machine-${each.key}.yaml.tmpl", { - ssh_keys = jsonencode(var.ssh_keys), - name = each.key - }) - strict = true -} +# data "ct_config" "machine-ignitions" { +# for_each = toset(var.machines) +# content = templatefile("${path.module}/cl/machine-${each.key}.yaml.tmpl", { +# ssh_keys = jsonencode(var.ssh_keys), +# name = each.key +# }) +# strict = true +# } output "ip-addresses" { value = {