Revert "wip: extend terraform module to support extra_files_script"

This reverts commit 9661aeffcb.

This was pushed by accident to main
This commit is contained in:
Jörg Thalheim 2023-09-05 15:22:07 +02:00
parent 9661aeffcb
commit 50e1df362e
5 changed files with 5 additions and 53 deletions

View File

@ -25,7 +25,6 @@ module "install" {
ssh_private_key = var.install_ssh_key
debug_logging = var.debug_logging
stop_after_disko = var.stop_after_disko
extra_files_script = var.extra_files_script
instance_id = var.instance_id
}

View File

@ -74,9 +74,3 @@ variable "stop_after_disko" {
description = "Exit after disko formatting"
default = false
}
variable "extra_files_script" {
type = string
description = "A script that prepares extra files to be copied to the target host during installation. The script expected to write all its files to the current directory. This directory is rsynced to the target host during installation to the / directory."
default = null
}

View File

@ -1,3 +1,7 @@
locals {
nixos_anywhere_flags = "${var.stop_after_disko ? "--stop-after-disko" : ""} ${var.debug_logging ? "--debug" : ""} ${var.kexec_tarball_url != null ? "--kexec ${var.kexec_tarball_url}" : "" } --store-paths ${var.nixos_partitioner} ${var.nixos_system} ${var.target_user}@${var.target_host}"
}
resource "null_resource" "nixos-remote" {
triggers = {
instance_id = var.instance_id
@ -5,16 +9,8 @@ resource "null_resource" "nixos-remote" {
provisioner "local-exec" {
environment = {
SSH_PRIVATE_KEY = var.ssh_private_key
stop_after_disko = var.stop_after_disko
debug_logging = var.debug_logging
kexec_tarball_url = var.kexec_tarball_url
nixos_partitioner = var.nixos_partitioner
nixos_system = var.nixos_system
target_user = var.target_user
target_host = var.target_host
extra_files_script = var.extra_files_script
}
command = "bash run-nixos-anywhere.sh"
command = "nix run --extra-experimental-features 'nix-command flakes' path:${path.module}/../..#nixos-anywhere -- ${local.nixos_anywhere_flags}"
quiet = var.debug_logging
}
}

View File

@ -1,31 +0,0 @@
# shellcheck shell=bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
args=()
if [[ ${debug_logging-} == "true" ]]; then
set -x
args+=("--debug")
fi
if [[ ${stop_after_disko-} == "true" ]]; then
args+=("--stop-after-disko")
fi
if [[ ${kexec_tarball_url-} != "" ]]; then
args+=("--kexec" "${kexec_tarball_url}")
fi
args+=("--store-paths" "${nixos_partitioner} ${nixos_system}")
if [[ ${extra_files_script-} != "" ]]; then
tmpdir=$(mktemp -d)
cleanup() {
rm -rf "${tmpdir}"
}
trap cleanup EXIT
pushd "${tmpdir}"
${extra_files_script}
popd
args+=("--extra-files" "${tmpdir}")
fi
args+=("${target_user}@${target_host}")
nix run --extra-experimental-features 'nix-command flakes' "path:${SCRIPT_DIR}/../..#nixos-anywhere" -- "${args[@]}"

View File

@ -56,9 +56,3 @@ variable "stop_after_disko" {
description = "Exit after disko formatting"
default = false
}
variable "extra_files_script" {
type = string
description = "A script that prepares extra files to be copied to the target host during installation. The script expected to write all its files to the current directory. This directory is rsynced to the target host during installation to the / directory."
default = null
}