Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf9af6e

Browse files
committed
example: Added Code-Server installation to hetzner template
1 parentbe89a0e commitbf9af6e

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

‎examples/hetzner-linux/cloud-config.yaml.tftpl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ users:
66
shell:/bin/bash
77
packages:
88
- git
9+
- curl
10+
- jq
911
mounts:
1012
- [
1113
"${volume_path}",
@@ -40,7 +42,31 @@ write_files:
4042

4143
[Install]
4244
WantedBy=multi-user.target
45+
%{ifcode_server_setup ~}
46+
-path:/tmp/install_code_server.sh
47+
permissions:"0777"
48+
content: |
49+
#!/bin/bash
50+
CODE_SERVER_DOWNLOAD_URL=$(curl-sL https://api.github.com/repos/coder/code-server/releases/latest | jq -r '.assets[].browser_download_url' | grep "amd64.deb")
51+
curl-fL $CODE_SERVER_DOWNLOAD_URL-o/tmp/code_server.deb
52+
dpkg-i/tmp/code_server.deb
53+
systemctl enable--now code-server@${username}
54+
rm/tmp/code_server.deb
55+
-path:/tmp/install_code_server.sh
56+
permissions:"0777"
57+
content: |
58+
-path:/home/${username}/.config/code-server/config.yaml
59+
permissions:"0644"
60+
content: |
61+
bind-addr:127.0.0.1:8080
62+
auth: none
63+
cert:false
64+
%{ endif ~}
4365
runcmd:
4466
- chown ${username}:${username}/home/${username}
4567
- systemctl enable coder-agent
4668
- systemctl start coder-agent
69+
%{ifcode_server_setup ~}
70+
-/tmp/install_code_server.sh
71+
- rm/tmp/install_code_server.sh
72+
%{ endif }

‎examples/hetzner-linux/main.tf

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ variable "volume_size" {
6565
}
6666
}
6767

68+
variable"code_server" {
69+
description="Should Code Server be installed?"
70+
default="true"
71+
validation {
72+
condition=contains(["true","false"], var.code_server)
73+
error_message="Your answer can only be yes or no!"
74+
}
75+
}
76+
6877
data"coder_workspace""me" {
6978
}
7079

@@ -73,17 +82,27 @@ resource "coder_agent" "dev" {
7382
os="linux"
7483
}
7584

85+
resource"coder_app""code-server" {
86+
count=var.code_server?1:0
87+
agent_id=coder_agent.dev.id
88+
name="code-server"
89+
icon="https://cdn.icon-icons.com/icons2/2107/PNG/512/file_type_vscode_icon_130084.png"
90+
url="http://localhost:8080"
91+
relative_path=true
92+
}
93+
7694
resource"hcloud_server""root" {
77-
count=data.coder_workspace.me.start_count
95+
count=data.coder_workspace.me.start_count
7896
name="coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
7997
server_type=var.instance_type
8098
location=var.instance_location
8199
image=var.instance_os
82-
user_data=templatefile("cloud-config.yaml.tftpl", {
100+
user_data=templatefile("cloud-config.yaml.tftpl", {
83101
username= data.coder_workspace.me.owner
84102
volume_path="/dev/disk/by-id/scsi-0HC_Volume_${hcloud_volume.root.id}"
85103
init_script=base64encode(coder_agent.dev.init_script)
86104
coder_agent_token= coder_agent.dev.token
105+
code_server_setup= var.code_server
87106
})
88107
}
89108

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp