Skip to content

Commit b699b30

Browse files
committed
terraform: add missing phases
1 parent 8714293 commit b699b30

File tree

7 files changed

+82
-64
lines changed

7 files changed

+82
-64
lines changed

terraform/all-in-one.md

Lines changed: 22 additions & 21 deletions
Large diffs are not rendered by default.

terraform/all-in-one/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ module "install" {
2727
nixos_system = module.system-build.result.out
2828
ssh_private_key = var.install_ssh_key
2929
debug_logging = var.debug_logging
30-
stop_after_disko = var.stop_after_disko
3130
extra_files_script = var.extra_files_script
3231
disk_encryption_key_scripts = var.disk_encryption_key_scripts
3332
extra_environment = var.extra_environment
3433
instance_id = var.instance_id
34+
phases = var.phases
35+
# deprecated attributes
36+
stop_after_disko = var.stop_after_disko
3537
no_reboot = var.no_reboot
3638
}
3739

terraform/all-in-one/variables.tf

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,22 @@ variable "debug_logging" {
7777

7878
variable "stop_after_disko" {
7979
type = bool
80-
description = "Exit after disko formatting"
80+
description = "DEPRECATED: Use `phases` instead. Exit after disko formatting"
8181
default = false
8282
}
8383

84+
variable "no_reboot" {
85+
type = bool
86+
description = "DEPRECATED: Use `phases` instead. Do not reboot after installation"
87+
default = false
88+
}
89+
90+
variable "phases" {
91+
type = set(string)
92+
description = "Phases to run"
93+
default = ["kexec", "disko", "install", "reboot"]
94+
}
95+
8496
variable "extra_files_script" {
8597
type = string
8698
description = "A script that should place files in the current directory that will be copied to the targets / directory"
@@ -102,12 +114,6 @@ variable "extra_environment" {
102114
default = {}
103115
}
104116

105-
variable "no_reboot" {
106-
type = bool
107-
description = "Do not reboot after installation"
108-
default = false
109-
}
110-
111117
variable "nix_options" {
112118
type = map(string)
113119
description = "the options of nix"

terraform/install.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,26 @@ No modules.
6161

6262
## Inputs
6363

64-
| Name | Description | Type | Default | Required |
65-
| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | -------- | :------: |
66-
| <a name="input_build_on_remote"></a> [build\_on\_remote](#input_build_on_remote) | Build the closure on the remote machine instead of building it locally and copying it over | `bool` | `false` | no |
67-
| <a name="input_debug_logging"></a> [debug\_logging](#input_debug_logging) | Enable debug logging | `bool` | `false` | no |
68-
| <a name="input_disk_encryption_key_scripts"></a> [disk\_encryption\_key\_scripts](#input_disk_encryption_key_scripts) | Each script will be executed locally. Output of each will be created at the given path to disko during installation. The keys will be not copied to the final system | <pre>list(object({<br> path = string<br> script = string<br> }))</pre> | `[]` | no |
69-
| <a name="input_extra_environment"></a> [extra\_environment](#input_extra_environment) | Extra environment variables to be set during installation. This can be useful to set extra variables for the extra\_files\_script or disk\_encryption\_key\_scripts | `map(string)` | `{}` | no |
70-
| <a name="input_extra_files_script"></a> [extra\_files\_script](#input_extra_files_script) | A script that should place files in the current directory that will be copied to the targets / directory | `string` | `null` | no |
71-
| <a name="input_flake"></a> [flake](#input_flake) | The flake to install the system from | `string` | `""` | no |
72-
| <a name="input_instance_id"></a> [instance\_id](#input_instance_id) | The instance id of the target\_host, used to track when to reinstall the machine | `string` | `null` | no |
73-
| <a name="input_kexec_tarball_url"></a> [kexec\_tarball\_url](#input_kexec_tarball_url) | NixOS kexec installer tarball url | `string` | `null` | no |
74-
| <a name="input_nixos_partitioner"></a> [nixos\_partitioner](#input_nixos_partitioner) | nixos partitioner and mount script | `string` | `""` | no |
75-
| <a name="input_nixos_system"></a> [nixos\_system](#input_nixos_system) | The nixos system to deploy | `string` | `""` | no |
76-
| <a name="input_no_reboot"></a> [no\_reboot](#input_no_reboot) | Do not reboot the machine after installation | `bool` | `false` | no |
77-
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input_ssh_private_key) | Content of private key used to connect to the target\_host | `string` | `""` | no |
78-
| <a name="input_stop_after_disko"></a> [stop\_after\_disko](#input_stop_after_disko) | Exit after disko formatting | `bool` | `false` | no |
79-
| <a name="input_target_host"></a> [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes |
80-
| <a name="input_target_port"></a> [target\_port](#input_target_port) | SSH port used to connect to the target\_host | `number` | `22` | no |
81-
| <a name="input_target_user"></a> [target\_user](#input_target_user) | SSH user used to connect to the target\_host | `string` | `"root"` | no |
64+
| Name | Description | Type | Default | Required |
65+
| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------- | :------: |
66+
| <a name="input_build_on_remote"></a> [build\_on\_remote](#input_build_on_remote) | Build the closure on the remote machine instead of building it locally and copying it over | `bool` | `false` | no |
67+
| <a name="input_debug_logging"></a> [debug\_logging](#input_debug_logging) | Enable debug logging | `bool` | `false` | no |
68+
| <a name="input_disk_encryption_key_scripts"></a> [disk\_encryption\_key\_scripts](#input_disk_encryption_key_scripts) | Each script will be executed locally. Output of each will be created at the given path to disko during installation. The keys will be not copied to the final system | <pre>list(object({<br> path = string<br> script = string<br> }))</pre> | `[]` | no |
69+
| <a name="input_extra_environment"></a> [extra\_environment](#input_extra_environment) | Extra environment variables to be set during installation. This can be useful to set extra variables for the extra\_files\_script or disk\_encryption\_key\_scripts | `map(string)` | `{}` | no |
70+
| <a name="input_extra_files_script"></a> [extra\_files\_script](#input_extra_files_script) | A script that should place files in the current directory that will be copied to the targets / directory | `string` | `null` | no |
71+
| <a name="input_flake"></a> [flake](#input_flake) | The flake to install the system from | `string` | `""` | no |
72+
| <a name="input_instance_id"></a> [instance\_id](#input_instance_id) | The instance id of the target\_host, used to track when to reinstall the machine | `string` | `null` | no |
73+
| <a name="input_kexec_tarball_url"></a> [kexec\_tarball\_url](#input_kexec_tarball_url) | NixOS kexec installer tarball url | `string` | `null` | no |
74+
| <a name="input_nixos_partitioner"></a> [nixos\_partitioner](#input_nixos_partitioner) | nixos partitioner and mount script | `string` | `""` | no |
75+
| <a name="input_nixos_system"></a> [nixos\_system](#input_nixos_system) | The nixos system to deploy | `string` | `""` | no |
76+
| <a name="input_no_reboot"></a> [no\_reboot](#input_no_reboot) | DEPRECATED: Use `phases` instead. Do not reboot after installation | `bool` | `false` | no |
77+
| <a name="input_phases"></a> [phases](#input_phases) | Phases to run | `list(string)` | <pre>[<br> "kexec",<br> "disko",<br> "install",<br> "reboot"<br>]</pre> | no |
78+
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input_ssh_private_key) | Content of private key used to connect to the target\_host | `string` | `""` | no |
79+
| <a name="input_stop_after_disko"></a> [stop\_after\_disko](#input_stop_after_disko) | DEPRECATED: Use `phases` instead. Exit after disko formatting | `bool` | `false` | no |
80+
| <a name="input_target_host"></a> [target\_host](#input_target_host) | DNS host to deploy to | `string` | n/a | yes |
81+
| <a name="input_target_pass"></a> [target\_pass](#input_target_pass) | Password used to connect to the target\_host | `string` | `null` | no |
82+
| <a name="input_target_port"></a> [target\_port](#input_target_port) | SSH port used to connect to the target\_host | `number` | `22` | no |
83+
| <a name="input_target_user"></a> [target\_user](#input_target_user) | SSH user used to connect to the target\_host | `string` | `"root"` | no |
8284

8385
## Outputs
8486

terraform/install/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
locals {
22
disk_encryption_key_scripts = [for k in var.disk_encryption_key_scripts : "\"${k.path}\" \"${k.script}\""]
3+
removed_phases = setunion(var.stop_after_disko ? ["install"] : [], (var.no_reboot ? ["reboot"] : []))
4+
phases = setsubstract(var.phases, removed_phases)
35
arguments = jsonencode({
46
ssh_private_key = var.ssh_private_key
5-
stop_after_disko = var.stop_after_disko
67
debug_logging = var.debug_logging
78
kexec_tarball_url = var.kexec_tarball_url
89
nixos_partitioner = var.nixos_partitioner
@@ -12,9 +13,9 @@ locals {
1213
target_port = var.target_port
1314
target_pass = var.target_pass
1415
extra_files_script = var.extra_files_script
15-
no_reboot = var.no_reboot
1616
build_on_remote = var.build_on_remote
1717
flake = var.flake
18+
phases = join(",", local.phases)
1819
})
1920
}
2021

terraform/install/variables.tf

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ variable "debug_logging" {
5959
default = false
6060
}
6161

62-
variable "stop_after_disko" {
63-
type = bool
64-
description = "Exit after disko formatting"
65-
default = false
66-
}
67-
6862
variable "extra_files_script" {
6963
type = string
7064
description = "A script that should place files in the current directory that will be copied to the targets / directory"
@@ -86,12 +80,24 @@ variable "extra_environment" {
8680
default = {}
8781
}
8882

83+
variable "stop_after_disko" {
84+
type = bool
85+
description = "DEPRECATED: Use `phases` instead. Exit after disko formatting"
86+
default = false
87+
}
88+
8989
variable "no_reboot" {
9090
type = bool
91-
description = "Do not reboot the machine after installation"
91+
description = "DEPRECATED: Use `phases` instead. Do not reboot after installation"
9292
default = false
9393
}
9494

95+
variable "phases" {
96+
type = list(string)
97+
description = "Phases to run"
98+
default = ["kexec", "disko", "install", "reboot"]
99+
}
100+
95101
variable "build_on_remote" {
96102
type = bool
97103
description = "Build the closure on the remote machine instead of building it locally and copying it over"

0 commit comments

Comments
 (0)