Skip to content

feat: Add examples/templates/do-linux for Digital Ocean Droplets #1749

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

Merged
merged 13 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Add support for coder user username
  • Loading branch information
mafredri committed May 25, 2022
commit 0b2c8d466a4edf240b1587dca0fa853eaaf82d15
8 changes: 4 additions & 4 deletions examples/do-droplet-linux/cloud-config.yaml.tftpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#cloud-config
users:
- name: coder
- name: ${username}
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
groups: sudo
shell: /bin/bash
Expand All @@ -9,7 +9,7 @@ packages:
mounts:
- [
"LABEL=${home_volume_label}",
/home/coder,
"/home/${username}",
auto,
"defaults,uid=1000,gid=1000",
]
Expand All @@ -27,7 +27,7 @@ write_files:
Wants=network-online.target

[Service]
User=coder
User=${username}
ExecStart=/opt/coder/init
Environment=CODER_AGENT_TOKEN=${coder_agent_token}
Restart=always
Expand All @@ -41,6 +41,6 @@ write_files:
[Install]
WantedBy=multi-user.target
runcmd:
- chown coder:coder /home/coder
- chown ${username}:${username} /home/${username}
- systemctl enable coder-agent
- systemctl start coder-agent
1 change: 1 addition & 0 deletions examples/do-droplet-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ resource "digitalocean_droplet" "workspace" {
size = var.droplet_size
volume_ids = [digitalocean_volume.home_volume.id]
user_data = templatefile("cloud-config.yaml.tftpl", {
username = data.coder_workspace.me.owner
home_volume_label = digitalocean_volume.home_volume.initial_filesystem_label
init_script = base64encode(coder_agent.dev.init_script)
coder_agent_token = coder_agent.dev.token
Expand Down