nixos-anywhere/terraform/all-in-one/main.tf
Jean-François Roche 16143cd8c0 terraform: allow nixos-rebuild to use specified private key for deployment
`nixos-rebuild/deploy.sh` script enable ssh authentication with a given private key
through the `SSH_KEY` environment variable.

Add additional variable for the private key used for the deployment.
To encourage the use of ssh-agent and discourage the storage of deployment keys in the terraform state
we do not set the install ssh key as the default for the deployment key.

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-03-28 00:28:48 +02:00

40 lines
1.0 KiB
HCL

module "system-build" {
source = "../nix-build"
attribute = var.nixos_system_attr
file = var.file
}
module "partitioner-build" {
source = "../nix-build"
attribute = var.nixos_partitioner_attr
file = var.file
}
locals {
install_user = var.install_user == null ? var.target_user : var.install_user
}
module "install" {
source = "../install"
kexec_tarball_url = var.kexec_tarball_url
target_user = local.install_user
target_host = var.target_host
target_port = var.target_port
nixos_partitioner = module.partitioner-build.result.out
nixos_system = module.system-build.result.out
ssh_private_key = var.install_ssh_key
debug_logging = var.debug_logging
instance_id = var.instance_id
}
module "nixos-rebuild" {
depends_on = [
module.install
]
source = "../nixos-rebuild"
nixos_system = module.system-build.result.out
ssh_private_key = var.deployment_ssh_key
target_host = var.target_host
target_user = var.target_user
}