File tree Expand file tree Collapse file tree 9 files changed +57
-5
lines changed Expand file tree Collapse file tree 9 files changed +57
-5
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Options:
21
21
* --env-password
22
22
set a password used by ssh-copy-id, the password should be set by
23
23
the environment variable SSHPASS. Additionally, sudo password can be set
24
- via SUDO_PASSWORD environment variable for remote sudo operations
24
+ via SUDO_PASSWORD environment variable for remote sudo operations
25
25
(only supported with sudo, not doas)
26
26
* -s, --store-paths <disko-script> <nixos-system>
27
27
set the store paths to the disko-script and nixos-system directly
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ Options:
42
42
* --env-password
43
43
set a password used by ssh-copy-id, the password should be set by
44
44
the environment variable SSHPASS. Additionally, sudo password can be set
45
- via SUDO_PASSWORD environment variable for remote sudo operations
45
+ via SUDO_PASSWORD environment variable for remote sudo operations
46
46
(only supported with sudo, not doas)
47
47
* -s, --store-paths <disko-script> <nixos-system>
48
48
set the store paths to the disko-script and nixos-system directly
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ module "deploy" {
28
28
# debug_logging = true
29
29
# build the closure on the remote machine instead of locally
30
30
# build_on_remote = true
31
+ # Optional: SSH password for initial installation
32
+ # install_pass = "your-ssh-password"
33
+ # Optional: Sudo password for remote operations during installation
34
+ # install_sudo_pass = "your-sudo-password"
31
35
# script is below
32
36
extra_files_script = "${path.module}/decrypt-ssh-secrets.sh"
33
37
disk_encryption_key_scripts = [{
@@ -139,7 +143,7 @@ locals {
139
143
resource "local_file" "nixos_vars" {
140
144
content = jsonencode(local.nixos_vars) # Converts variables to JSON
141
145
filename = local.nixos_vars_file # Specifies the output file path
142
- file_permission = "600"
146
+ file_permission = "600"
143
147
144
148
# Automatically adds the generated file to Git
145
149
provisioner "local-exec" {
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ module "install" {
27
27
target_user = local. install_user
28
28
target_host = var. target_host
29
29
target_port = local. install_port
30
+ target_pass = var. install_pass
31
+ target_sudo_pass = var. install_sudo_pass
30
32
nixos_partitioner = module. partitioner-build . result . out
31
33
nixos_system = module. system-build . result . out
32
34
ssh_private_key = var. install_ssh_key
Original file line number Diff line number Diff line change @@ -149,3 +149,17 @@ variable "install_bootloader" {
149
149
description = " Install/re-install the bootloader"
150
150
default = false
151
151
}
152
+
153
+ variable "install_pass" {
154
+ type = string
155
+ description = " Password used to connect to the target_host during installation"
156
+ default = null
157
+ sensitive = true
158
+ }
159
+
160
+ variable "install_sudo_pass" {
161
+ type = string
162
+ description = " Sudo password for remote sudo operations during installation. Only supported with sudo, not doas."
163
+ default = null
164
+ sensitive = true
165
+ }
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ module "install" {
34
34
nixos_system = module.system-build.result.out
35
35
nixos_partitioner = module.disko.result.out
36
36
target_host = local.ipv4
37
+ # Optional: SSH password authentication
38
+ # target_pass = "your-ssh-password"
39
+ # Optional: Sudo password for remote operations
40
+ # target_sudo_pass = "your-sudo-password"
37
41
}
38
42
```
39
43
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ locals {
12
12
target_host = var.target_host
13
13
target_port = var.target_port
14
14
target_pass = var.target_pass
15
+ target_sudo_pass = var.target_sudo_pass
15
16
extra_files_script = var.extra_files_script
16
17
build_on_remote = var.build_on_remote
17
18
flake = var.flake
Original file line number Diff line number Diff line change @@ -13,7 +13,14 @@ args=()
13
13
14
14
if [[ ${input[debug_logging]} == " true" ]]; then
15
15
set -x
16
- declare -p input
16
+ # Print input variables but filter out sensitive passwords
17
+ for key in " ${! input[@]} " ; do
18
+ if [[ $key == * " pass" * ]]; then
19
+ echo " input[$key ]='[FILTERED]'"
20
+ else
21
+ echo " input[$key ]='${input[$key]} '"
22
+ fi
23
+ done
17
24
args+=(" --debug" )
18
25
fi
19
26
if [[ ${input[kexec_tarball_url]} != " null" ]]; then
@@ -40,9 +47,22 @@ args+=(--phases "${input[phases]}")
40
47
if [[ ${input[ssh_private_key]} != null ]]; then
41
48
export SSH_PRIVATE_KEY=" ${input[ssh_private_key]} "
42
49
fi
50
+ if [[ ${input[target_pass]} != null || ${input[target_sudo_pass]} != null ]]; then
51
+ args+=(" --env-password" )
52
+ fi
53
+ # Temporarily disable debug output when exporting sensitive variables
54
+ if [[ ${input[debug_logging]} == " true" ]]; then
55
+ set +x
56
+ fi
43
57
if [[ ${input[target_pass]} != null ]]; then
44
58
export SSHPASS=${input[target_pass]}
45
- args+=(" --env-password" )
59
+ fi
60
+ if [[ ${input[target_sudo_pass]} != null ]]; then
61
+ export SUDO_PASSWORD=${input[target_sudo_pass]}
62
+ fi
63
+ # Re-enable debug output if it was enabled
64
+ if [[ ${input[debug_logging]} == " true" ]]; then
65
+ set -x
46
66
fi
47
67
48
68
tmpdir=$( mktemp -d)
Original file line number Diff line number Diff line change @@ -41,6 +41,13 @@ variable "target_pass" {
41
41
default = null
42
42
}
43
43
44
+ variable "target_sudo_pass" {
45
+ type = string
46
+ description = " Sudo password for remote sudo operations on target_host. Only supported with sudo, not doas."
47
+ default = null
48
+ sensitive = true
49
+ }
50
+
44
51
variable "ssh_private_key" {
45
52
type = string
46
53
description = " Content of private key used to connect to the target_host"
You can’t perform that action at this time.
0 commit comments