mingfang
mingfang
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
it's still a problem. I think the coder above may be the problem; i think the stop scripts should run before the ssh server is shutdown
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
that caused a validation error
Error: "start_blocks_login" can only be set if "run_on_start" is "true"
Error: "start_blocks_login" can only be set if "run_on_start" is "true"
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
It turns out the shutdown script is running but it didn't get a chance to finish. I'm guessing it is because the ssh server got killed before the script gets a chance to finish. Here is the part of the agent log that shows the shutdown sequence.
2025-01-31 09:21:29.701 [info] shutting down agent
2025-01-31 09:21:29.701 [debu] set lifecycle state current={"state":"shutting_down","changed_at":"2025-01-31T09:21:29.701491Z"} last={"state":"ready","changed_at":"2025-01-31T09:18:49.701169Z"}
2025-01-31 09:21:29.701 [info] ssh-server: stopped serving listener listen_addr={} ...
2025-01-31 09:21:29.701 [info] running agent script log_source_id=ac47a7e3-34a9-44e6-8fdd-b94a9ec8cc5d log_path=/home/coder/shutdow.log script_data_dir=/tmp/coder-script-data/ac47a7e3-34a9-44e6-8fdd-b94a9ec8cc5d ...
script= #!/bin/sh
cd "/home/coder/repo/examples/postgrest"
terraform destroy -auto-approve
echo "bye bye bye"
2025-01-31 09:21:30.196 [info] connecting to coderd
2025-01-31 09:21:30.200 [warn] run exited with error ...
2025-01-31 09:21:29.701 [info] shutting down agent
2025-01-31 09:21:29.701 [debu] set lifecycle state current={"state":"shutting_down","changed_at":"2025-01-31T09:21:29.701491Z"} last={"state":"ready","changed_at":"2025-01-31T09:18:49.701169Z"}
2025-01-31 09:21:29.701 [info] ssh-server: stopped serving listener listen_addr={} ...
2025-01-31 09:21:29.701 [info] running agent script log_source_id=ac47a7e3-34a9-44e6-8fdd-b94a9ec8cc5d log_path=/home/coder/shutdow.log script_data_dir=/tmp/coder-script-data/ac47a7e3-34a9-44e6-8fdd-b94a9ec8cc5d ...
script= #!/bin/sh
cd "/home/coder/repo/examples/postgrest"
terraform destroy -auto-approve
echo "bye bye bye"
2025-01-31 09:21:30.196 [info] connecting to coderd
2025-01-31 09:21:30.200 [warn] run exited with error ...
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
Here is the build log
Initializing provider plugins...
- Finding latest version of hashicorp/kubernetes...
- Finding coder/coder versions matching ">= 0.17.0"...
- Installing hashicorp/kubernetes v2.35.1...
- Installed hashicorp/kubernetes v2.35.1 (signed by HashiCorp)
- Installing coder/coder v2.1.2...
- Installed coder/coder v2.1.2 (signed by a HashiCorp partner, key ID 93C75807601AA0EC)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
Initializing provider plugins...
- Finding latest version of hashicorp/kubernetes...
- Finding coder/coder versions matching ">= 0.17.0"...
- Installing hashicorp/kubernetes v2.35.1...
- Installed hashicorp/kubernetes v2.35.1 (signed by HashiCorp)
- Installing coder/coder v2.1.2...
- Installed coder/coder v2.1.2 (signed by a HashiCorp partner, key ID 93C75807601AA0EC)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
I don't have a lock file.
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
https://github.com/mingfang/coder-templates/blob/master/catalog/providers.tf I left it blank so it should be the "latest", correct?
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
My template is made up of several Terraform files. https://github.com/mingfang/coder-templates/tree/master/catalog The shutdow script is here https://github.com/mingfang/coder-templates/blob/master/catalog/main.tf#L108 The purpose of this template is to provide a catalog of services to try out. The service should start and shutdown along of the workspace. You can click on the link to the service(e.g. Kestra) from github to try it yourself.
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
Sorry I was not being clear. I'm trying to run a script on stop and not on delete. I've tried these and they are not working.
resource "coder_agent" "pod" {
shutdown_script = <<-EOT
echo "this does not get run on stop"
EOT
}
resource "coder_agent" "pod" {
shutdown_script = <<-EOT
echo "this does not get run on stop"
EOT
}
and
resource "coder_script" "shutdown" {
agent_id = coder_agent.pod.id
run_on_stop = true
script = <<-EOF
echo "this does not get run on stop"
EOF
}
resource "coder_script" "shutdown" {
agent_id = coder_agent.pod.id
run_on_stop = true
script = <<-EOF
echo "this does not get run on stop"
EOF
}
Question is...why is this not working?
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
@Phorcys thanks for the explanation. for my use case I need the script to run on the workspace. i was hoping that I can use coder_script https://registry.terraform.io/providers/coder/coder/latest/docs/resources/script#run_on_stop-1 but i have not been able to get a simple echo hello to work
45 replies
CCoder.com
Created by Conor on 2/23/2024 in #help
How does the coder_script terraform resource work?
I have the same use case; I need to manually stop some external processes on shutdown. How can local-exec help in this case?
45 replies