Storing variables in self.triggers
This commit is contained in:
parent
da457b3f9d
commit
c2fbe6be56
1 changed files with 11 additions and 7 deletions
|
|
@ -46,6 +46,10 @@ resource "random_id" "cluster_suffix" {
|
|||
|
||||
resource "null_resource" "talos_cluster" {
|
||||
triggers = {
|
||||
cluster_name = local.unique_cluster_name
|
||||
memory_mb = var.memory_mb
|
||||
vcpu_count = var.vcpu_count
|
||||
talos_version = var.talos_version
|
||||
config_hash = sha1(join("", [
|
||||
locals.unique_cluster_name,
|
||||
tostring(var.memory_mb),
|
||||
|
|
@ -59,8 +63,8 @@ resource "null_resource" "talos_cluster" {
|
|||
provisioner "local-exec" {
|
||||
command = <<EOT
|
||||
mkdir -p _out/
|
||||
curl -L -o _out/vmlinuz-arm64 https://github.com/siderolabs/talos/releases/download/${var.talos_version}/vmlinuz-arm64
|
||||
curl -L -o _out/initramfs-arm64.xz https://github.com/siderolabs/talos/releases/download/${var.talos_version}/initramfs-arm64.xz
|
||||
curl -L -o _out/vmlinuz-arm64 https://github.com/siderolabs/talos/releases/download/${self.triggers.talos_version}/vmlinuz-arm64
|
||||
curl -L -o _out/initramfs-arm64.xz https://github.com/siderolabs/talos/releases/download/${self.triggers.talos_version}/initramfs-arm64.xz
|
||||
EOT
|
||||
}
|
||||
|
||||
|
|
@ -72,12 +76,12 @@ resource "null_resource" "talos_cluster" {
|
|||
echo "Creating new cluster..."
|
||||
sudo --preserve-env=HOME talosctl cluster create \
|
||||
--provisioner=qemu \
|
||||
--name ${locals.unique_cluster_name} \
|
||||
--name ${self.triggers.cluster_name} \
|
||||
--talosconfig ${path.module}/talosconfig \
|
||||
--controlplanes 1 \
|
||||
--workers 0 \
|
||||
--memory ${var.memory_mb} \
|
||||
--cpus ${var.vcpu_count}
|
||||
--memory ${self.triggers.memory_mb} \
|
||||
--cpus ${self.triggers.vcpu_count}
|
||||
|
||||
# Change ownership of the generated files in ~/.talos and ~/.kube
|
||||
sudo chown -R $(whoami):admin $(HOME)/.talos
|
||||
|
|
@ -90,11 +94,11 @@ resource "null_resource" "talos_cluster" {
|
|||
command = <<EOT
|
||||
sudo --preserve-env=HOME talosctl cluster destroy \
|
||||
--provisioner=qemu \
|
||||
--name ${locals.unique_cluster_name}
|
||||
--name ${self.triggers.cluster_name}
|
||||
|
||||
# Call cleanup script
|
||||
chmod +x ${path.module}/cleanup.sh
|
||||
${path.module}/cleanup.sh ${locals.unique_cluster_name}
|
||||
${path.module}/cleanup.sh ${self.triggers.cluster_name}
|
||||
EOT
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue