Skip to content

Commit

Permalink
terraform: add missing phases
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Sep 16, 2024
1 parent 43cf165 commit 2eb9196
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
4 changes: 3 additions & 1 deletion terraform/all-in-one/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ module "install" {
nixos_system = module.system-build.result.out
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
disk_encryption_key_scripts = var.disk_encryption_key_scripts
extra_environment = var.extra_environment
instance_id = var.instance_id
phases = var.phases
# deprecated attributes
stop_after_disko = var.stop_after_disko
no_reboot = var.no_reboot
}

Expand Down
20 changes: 13 additions & 7 deletions terraform/all-in-one/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,22 @@ variable "debug_logging" {

variable "stop_after_disko" {
type = bool
description = "Exit after disko formatting"
description = "DEPRECATED: Use `phases` instead. Exit after disko formatting"
default = false
}

variable "no_reboot" {
type = bool
description = "DEPRECATED: Use `phases` instead. Do not reboot after installation"
default = false
}

variable "phases" {
type = set(string)
description = "Phases to run"
default = ["kexec", "disko", "install", "reboot"]
}

variable "extra_files_script" {
type = string
description = "A script that should place files in the current directory that will be copied to the targets / directory"
Expand All @@ -102,12 +114,6 @@ variable "extra_environment" {
default = {}
}

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

variable "nix_options" {
type = map(string)
description = "the options of nix"
Expand Down
5 changes: 3 additions & 2 deletions terraform/install/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
locals {
disk_encryption_key_scripts = [for k in var.disk_encryption_key_scripts : "\"${k.path}\" \"${k.script}\""]
removed_phases = setunion(var.stop_after_disko ? ["install"] : [], (var.no_reboot ? ["reboot"] : []))
phases = setsubstract(var.phases, removed_phases)
arguments = jsonencode({
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
Expand All @@ -12,9 +13,9 @@ locals {
target_port = var.target_port
target_pass = var.target_pass
extra_files_script = var.extra_files_script
no_reboot = var.no_reboot
build_on_remote = var.build_on_remote
flake = var.flake
phases = join(",", local.phases)
})
}

Expand Down
20 changes: 13 additions & 7 deletions terraform/install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ variable "debug_logging" {
default = false
}

variable "stop_after_disko" {
type = bool
description = "Exit after disko formatting"
default = false
}

variable "extra_files_script" {
type = string
description = "A script that should place files in the current directory that will be copied to the targets / directory"
Expand All @@ -86,12 +80,24 @@ variable "extra_environment" {
default = {}
}

variable "stop_after_disko" {
type = bool
description = "DEPRECATED: Use `phases` instead. Exit after disko formatting"
default = false
}

variable "no_reboot" {
type = bool
description = "Do not reboot the machine after installation"
description = "DEPRECATED: Use `phases` instead. Do not reboot after installation"
default = false
}

variable "phases" {
type = list(string)
description = "Phases to run"
default = ["kexec", "disko", "install", "reboot"]
}

variable "build_on_remote" {
type = bool
description = "Build the closure on the remote machine instead of building it locally and copying it over"
Expand Down

0 comments on commit 2eb9196

Please sign in to comment.