-
Notifications
You must be signed in to change notification settings - Fork 6
/
cloud-config.yaml.tftpl
69 lines (66 loc) · 1.74 KB
/
cloud-config.yaml.tftpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#cloud-config
users:
- name: ${username}
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
groups: sudo
shell: /bin/bash
packages:
- git
- curl
- jq
mounts:
- [
"${volume_path}",
"/home/${username}",
ext4,
"discard,defaults",
]
write_files:
- path: /opt/coder/init
permissions: "0755"
encoding: b64
content: ${init_script}
- path: /etc/systemd/system/coder-agent.service
permissions: "0644"
content: |
[Unit]
Description=Coder Agent
After=network-online.target
Wants=network-online.target
[Service]
User=${username}
ExecStart=/opt/coder/init
Environment=CODER_AGENT_TOKEN=${coder_agent_token}
Restart=always
RestartSec=10
TimeoutStopSec=90
KillMode=process
OOMScoreAdjust=-900
SyslogIdentifier=coder-agent
[Install]
WantedBy=multi-user.target
%{ if code_server_setup ~}
- path: /tmp/install_code_server.sh
permissions: "0777"
content: |
#!/bin/bash
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")
curl -fL $CODE_SERVER_DOWNLOAD_URL -o /tmp/code_server.deb
dpkg -i /tmp/code_server.deb
systemctl enable --now code-server@${username}
rm /tmp/code_server.deb
- path: /home/${username}/.config/code-server/config.yaml
permissions: "0644"
content: |
bind-addr: 127.0.0.1:8080
auth: none
cert: false
%{ endif ~}
runcmd:
- chown ${username}:${username} /home/${username}
- systemctl enable coder-agent
- systemctl start coder-agent
%{ if code_server_setup ~}
- /tmp/install_code_server.sh
- rm /tmp/install_code_server.sh
%{ endif }