-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform-nixos doesn't work on Terraform Cloud #41
Comments
Maybe it's because I forgot to run |
Ah no I have the same message. |
It's as the error says, |
I'm running this on NixOS. |
Are you using Terraform Cloud by any chance? If the execution is done on the remote worker it won't have nix-instantiate installed. |
Yes, sorry. I didn't realize I was using it. I'm guessing there's no way around that. Thanks. |
Would you be interested in investigating this if it was possible? |
resource "null_resource" "cluster" {
provisioner "local-exec" {
command = "sh <(curl -L https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210126_f15f0b8/install)"
interpreter = ["bash", "-c"]
}
} module "deploy_nixos" {
source = "git::https://github.com/tweag/terraform-nixos.git//deploy_nixos?ref=5f5a0408b299874d6a29d1271e9bffeee4c9ca71"
nixos_config = "${path.module}/configuration.nix"
target_host = aws_instance.machine.public_ip
ssh_private_key_file = local_file.machine_ssh_key.filename
ssh_agent = false
depends_on = [ "null_resource.cluster" ]
}
https://www.terraform.io/docs/cloud/run/install-software.html#only-install-standalone-binaries |
It's a bit of uncharted territory so I am not sure it will work. Ideally something like this would work:
Unfortunately, Another approach would be to use nix-user-chroot. Another thing to figure out is if Terraform Cloud provides any user-writable location in the PATH. If not, deploy_nixos could be extended with an option to set the PATH, or point to the folder that contains the Nix installation. |
Could https://github.com/DavHau/nix-portable also help with this? |
Yes, that might also be a good fallback |
I tried but got some error.
terraform {
backend "remote" {
organization = "bbigras"
workspaces {
name = "test-nix-portable"
}
}
}
resource "null_resource" "cluster" {
provisioner "local-exec" {
command = "curl https://gitlab.com/proot/proot/-/jobs/981080842/artifacts/raw/dist/proot > proot"
}
provisioner "local-exec" {
command = "chmod u+x proot"
}
provisioner "local-exec" {
command = "ls -l /home/terraform"
}
provisioner "local-exec" {
command = "/terraform/proot --help"
}
provisioner "local-exec" {
command = "ls -l"
}
provisioner "local-exec" {
command = "pwd"
}
provisioner "local-exec" {
command = "bash <(curl -L https://github.com/DavHau/nix-portable/releases/download/v003/nix-portable)"
interpreter = ["bash", "-c"]
environment = {
NP_PROOT = "/terraform/proot"
NP_RUNTIME = "proot"
NP_DEBUG = "1"
# NP_RUNTIME = "bwrap"
}
}
}
provider "aws" {
region = "ca-central-1"
}
module "nixos_image" {
source = "git::https://github.com/tweag/terraform-nixos.git//aws_image_nixos?ref=5f5a0408b299874d6a29d1271e9bffeee4c9ca71"
release = "20.09"
}
resource "aws_instance" "machine" {
ami = module.nixos_image.ami
instance_type = "t3.micro"
root_block_device {
volume_size = 50 # GiB
}
}
module "deploy_nixos" {
source = "git::https://github.com/tweag/terraform-nixos.git//deploy_nixos?ref=5f5a0408b299874d6a29d1271e9bffeee4c9ca71"
target_host = aws_instance.machine.public_ip
ssh_agent = false
depends_on = [ null_resource.cluster ]
} log
|
Terraform Cloud is what the tutorial referencing this module recommends using; I'll ping @domenkozar as it looks like he is in charge of the nix.dev site. |
https://nix.dev recommends "CLI-driven workflow" option, which means you deploy via a command line but still have logs, etc in the terraform cloud. |
Following the workflow detailed at https://nix.dev/tutorials/deploying-nixos-using-terraform.html results in a
Both @bbigras and I have encountered this error. Perhaps the article can be updated with the method you've indicated? |
@worldofgeese where are you running that command, locally? It requires to have Nix installed (that should be added). |
@domenkozar from my local host that has |
@worldofgeese I've added step 5 to https://deploy-preview-125--nixdev.netlify.app/tutorials/deploying-nixos-using-terraform.html#booting-nixos-image - do you think it's correct now? |
@domenkozar looks great to me! Thank you! |
Describe the bug
To Reproduce
Follow the guide at https://nixos.org/guides/deploying-nixos-using-terraform.html (it's at the part with the configuration.nix file).
Expected behavior
Environment
"x86_64-linux"
Linux 5.10.1-zen1, NixOS, 21.03.20210109.257cbbc (Okapi)
yes
yes
nix-env (Nix) 2.4pre20201205_a5d85d0
"nixos-21.03pre260232.733e537a8ad"
"home-manager-20.09"
/nix/var/nix/profiles/per-user/root/channels/nixos
Terraform v0.14.4
I tried with 5f5a040 and f0f6232.
Additional context
The text was updated successfully, but these errors were encountered: