Working with centralized config
This commit is contained in:
11
Makefile
Normal file
11
Makefile
Normal file
@@ -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
|
||||
@@ -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!
|
||||
|
||||
@@ -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
|
||||
@@ -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"}]}}
|
||||
12
flatcar/Makefile
Normal file
12
flatcar/Makefile
Normal file
@@ -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
|
||||
@@ -1,5 +1,10 @@
|
||||
variant: flatcar
|
||||
version: 1.1.0
|
||||
passwd:
|
||||
users:
|
||||
- name: core
|
||||
ssh_authorized_keys:
|
||||
- ""
|
||||
systemd:
|
||||
units:
|
||||
- name: app.service
|
||||
19
main.tf
19
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 = {
|
||||
|
||||
Reference in New Issue
Block a user