coder-template/hetzner-cloud/cloud-config.yaml.tftpl
Peter Kurfer 929efba70c
All checks were successful
Renovate / renovate (push) Successful in 11s
Hetzner Cloud template / hetzner-cloud-template (push) Successful in 24s
chore: order cloud-init config
2023-12-21 16:14:23 +01:00

118 lines
No EOL
3.2 KiB
Text

#cloud-config
users:
- name: ${username}
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
groups: sudo
shell: ${user_shell}
packages:
- zsh
- git
- git-delta
- difftastic
- curl
- jq
- htop
- exa
- ripgrep
- bat
- fzf
- dnf-plugins-core
- icu
- neovim
%{ if install_podman_setup ~}
- podman
- podman-docker
- docker-compose
- skopeo
- buildah
%{ endif ~}
mounts:
- [
"${volume_path}",
"/home/${username}",
ext4,
"discard,rw,suid,exec,auto,async",
]
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 install_podman_setup ~}
- path: /etc/profile.d/podman.sh
permissions: "0644"
content: |
export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock
%{ endif ~}
%{ if remote_ide_setup == "fleet" ~}
- path: /etc/systemd/system/fleet.service
permissions: "0644"
content: |
[Unit]
Description=Fleet
After=network-online.target
Wants=network-online.target
[Service]
User=${username}
ExecStart=/usr/local/bin/fleet launch workspace --version ${fleet_version} -- --auth=accept-everyone --enableSmartMode --workspacePort 3500
Restart=always
RestartSec=10
TimeoutStopSec=90
KillMode=process
SyslogIdentifier=fleet
[Install]
WantedBy=multi-user.target
%{ endif ~}
%{ if remote_ide_setup == "code_server" ~}
- 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 -R ${username}:${username} /home/${username}
- systemctl enable --now coder-agent
%{ if install_podman_setup ~}
- loginctl enable-linger ${username}
- mkdir -p /home/${username}/.config/systemd/user/sockets.target.wants
- ln -sf /usr/lib/systemd/system/podman.socket /home/${username}/.config/systemd/user/sockets.target.wants/
- chown -R ${username}:${username} /home/${username}
- sudo -u ${username} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" systemctl --user start podman
%{ endif ~}
%{ if remote_ide_setup == "code_server" ~}
- curl -fsSL https://code-server.dev/install.sh | sh
- systemctl enable --now code-server@${username}
%{ endif }
%{ if remote_ide_setup == "fleet" ~}
- curl -LSs "https://download.jetbrains.com/product?code=FLL&release.type=preview&release.type=eap&platform=$([ $(uname -m) = 'aarch64' ] && echo linux_aarch64 || echo linux_x64)" --output /usr/local/bin/fleet && chmod +x /usr/local/bin/fleet
- systemctl enable --now fleet
%{ endif }
- chown -R ${username}:${username} /home/${username}
- sh -c "$(curl -fsLS get.chezmoi.io)"