fix: use sudo for /opt/coder setup in cli_setup_wizard and install_skills
Provision Coder Templates / provision (push) Successful in 2m5s

The coder_agent's coder_script resources run as the unprivileged coder
user, which can't mkdir under root-owned /opt. Every template hit this
identically (mkdir: cannot create directory '/opt/coder': Permission
denied) since coder_script content is shared verbatim across all 6.
coder has passwordless sudo everywhere, so sudo mkdir + chown to the
running user unblocks the rest of each script's non-sudo writes.
This commit is contained in:
2026-08-26 18:38:46 +02:00
parent 1be7c00b84
commit 354536dad5
6 changed files with 24 additions and 12 deletions
+4 -2
View File
@@ -250,7 +250,8 @@ resource "coder_script" "cli_setup_wizard" {
script = <<-EOT
#!/bin/bash
set -e
mkdir -p /opt/coder
sudo mkdir -p /opt/coder
sudo chown "$(id -u):$(id -g)" /opt/coder
echo '${base64encode(file("${path.module}/cli-setup-wizard.sh"))}' | base64 -d > /opt/coder/cli-setup-wizard.sh
chmod +x /opt/coder/cli-setup-wizard.sh
@@ -305,7 +306,8 @@ resource "coder_script" "install_skills" {
script = <<-EOT
#!/bin/bash
set -e
mkdir -p /opt/coder
sudo mkdir -p /opt/coder
sudo chown "$(id -u):$(id -g)" /opt/coder
echo '${base64encode(file("${path.module}/install-skills.sh"))}' | base64 -d > /opt/coder/install-skills.sh
chmod +x /opt/coder/install-skills.sh
SPECIALTY_SKILLS="cobol-teacher" /opt/coder/install-skills.sh