Skip to content

Commit

Permalink
terraform: add no-reboot option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Sep 3, 2023
1 parent 1cf3fd1 commit 414aa45
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions terraform/all-in-one/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module "install" {
disk_encryption_key_scripts = var.disk_encryption_key_scripts
extra_environment = var.extra_environment
instance_id = var.instance_id
no_reboot = var.no_reboot
}

module "nixos-rebuild" {
Expand Down
6 changes: 6 additions & 0 deletions terraform/all-in-one/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ variable "extra_environment" {
description = "Extra environment variables to be set during installation. This can be usefull to set extra variables for the extra_files_script or disk_encryption_key_scripts"
default = {}
}

variable "no_reboot" {
type = bool
description = "Do not reboot after installation"
default = false
}
1 change: 1 addition & 0 deletions terraform/install/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resource "null_resource" "nixos-remote" {
target_user = var.target_user
target_host = var.target_host
extra_files_script = var.extra_files_script
no_reboot = var.no_reboot
}, var.extra_environment)
command = "${path.module}/run-nixos-anywhere.sh ${join(" ", local.disk_encryption_key_scripts)}"
quiet = var.debug_logging
Expand Down
6 changes: 5 additions & 1 deletion terraform/install/run-nixos-anywhere.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
set -euo pipefail -x

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
args=()
Expand All @@ -13,6 +13,9 @@ fi
if [[ ${kexec_tarball_url-} != "" ]]; then
args+=("--kexec" "${kexec_tarball_url}")
fi
if [[ ${no_reboot-} == "true" ]]; then
args+=("--no-reboot")
fi
args+=("--store-paths" "${nixos_partitioner}" "${nixos_system}")

tmpdir=$(mktemp -d)
Expand Down Expand Up @@ -51,6 +54,7 @@ while [[ $# -gt 0 ]]; do
fi
mkdir "${tmpdir}/keys"
"$2" >"${tmpdir}/keys/$keyIdx"
cat "${tmpdir}/keys/$keyIdx"
args+=("--disk-encryption-keys" "$1" "$2")
shift
shift
Expand Down
6 changes: 6 additions & 0 deletions terraform/install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ variable "extra_environment" {
description = "Extra environment variables to be set during installation. This can be usefull to set extra variables for the extra_files_script or disk_encryption_key_scripts"
default = {}
}

variable "no_reboot" {
type = bool
description = "Do not reboot the machine after installation"
default = false
}

0 comments on commit 414aa45

Please sign in to comment.