Skip to content

Commit

Permalink
terraform: only set SSHPASS and SSH_PRIVATE_KEY if values are not null
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored and mergify[bot] committed Sep 24, 2024
1 parent abbe975 commit df96ab6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions terraform/install/run-nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ if [[ -n ${input[flake]} ]]; then
else
args+=("--store-paths" "${input[nixos_partitioner]}" "${input[nixos_system]}")
fi
if [[ -n ${SSHPASS-} ]]; then
args+=(--phases "${input[phases]}")
if [[ ${input[ssh_private_key]} != null ]]; then
export SSH_PRIVATE_KEY="${input[ssh_private_key]}"
fi
if [[ ${input[target_pass]} != null ]]; then
export SSHPASS=${input[target_pass]}
args+=("--env-password")
fi
args+=(--phases "${input[phases]}")

tmpdir=$(mktemp -d)
cleanup() {
Expand Down Expand Up @@ -76,4 +80,4 @@ while [[ $# -gt 0 ]]; do
keyIdx=$((keyIdx + 1))
done

SSHPASS=${input[target_pass]} SSH_PRIVATE_KEY="${input[ssh_private_key]}" nix run --extra-experimental-features 'nix-command flakes' "path:${SCRIPT_DIR}/../..#nixos-anywhere" -- "${args[@]}"
nix run --extra-experimental-features 'nix-command flakes' "path:${SCRIPT_DIR}/../..#nixos-anywhere" -- "${args[@]}"

0 comments on commit df96ab6

Please sign in to comment.