Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
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
14 changes: 14 additions & 0 deletions .icons/vsphere.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added registry/anis/.images/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions registry/anis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
display_name: "Anis Khalfallah"
bio: "DevOps Engineer"
github: "aniskhalfallah"
avatar: "./.images/avatar.png"
linkedin: "https://www.linkedin.com/in/khalfallah-anis/"
status: "community"
---

# Anis KHALFALLAH

DevOps Engineer
81 changes: 81 additions & 0 deletions registry/anis/templates/vmware-linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
display_name: VMware vSphere VM (Linux)
description: Provision VMware vSphere virtual machines as Coder workspaces
icon: ../../../../.icons/vsphere.svg
verified: false
tags: [vm, linux, vmware, vsphere]
---

# Summary

Provision VMware vSphere virtual machines as [Coder workspaces](https://coder.com/docs/workspaces) using this Terraform template.

## Prerequisites

To deploy Coder workspaces on VMware vSphere, you'll need the following:

### vSphere Resources

Before deploying, ensure your vSphere environment has:

- A **vSphere Datacenter** already created
- A **Compute Cluster** within that datacenter
- A **Datastore** with sufficient storage capacity
- A **Network** (port group) accessible by VMs
- A **VM Template** with Ubuntu and cloud-init configured

### VM Template Requirements

Your VM template must have

- **cloud-init** installed and configured for VMware datasource

### vSphere Authentication

You'll need the following credentials:

- **vSphere Server** (hostname or IP)
- **Username**
- **Password**
- **Datacenter Name**
- **Cluster Name**
- **Datastore Name**
- **Network Name**
- **VM Template Name**

[VMware Provider Documentation](https://registry.terraform.io/providers/hashicorp/vsphere/latest/docs)

---

## Example `.tfvars` File

```hcl
vsphere_server = "vcenter.example.com"
vsphere_username = "[email protected]"
vsphere_password = "YourSecurePassword123!"
vsphere_datacenter = "DC01"
cluster_name = "Cluster01"
vsphere_datastore = "datastore1"
vsphere_network = "VM Network"
vm_template = "ubuntu-22.04-cloud-init-template"
```

---

## Architecture

This template creates:

- A **vSphere Virtual Machine** per workspace
- **Dynamic resource allocation** (CPU, memory configurable by users)
- **Two disks**: root disk (from template) and separate home volume
- **Coder agent** installed via cloud-init
- **code-server** for browser-based VS Code access

## Workspace Parameters

Users can customize their workspace with:

- **VCPUs**: 1, 2, 4, or 8 virtual CPUs
- **Memory**: 1, 2, 4, 8, 16, or 32 GB RAM
- **Home Volume Size**: 10-1024 GB (default: 20 GB)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#cloud-config
hostname: ${hostname}
users:
- name: ${username}
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
groups: sudo
shell: /bin/bash
packages:
- git
- curl
- wget
- unzip
disk_setup:
/dev/sdb:
table_type: "gpt"
layout: true
overwrite: false
fs_setup:
- label: ${home_volume_label}
filesystem: ext4
device: /dev/sdb
partition: auto
mounts:
- ["/dev/sdb", "/home/${username}", "ext4", "defaults", "0", "2"]
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=-1000
SyslogIdentifier=coder-agent

[Install]
WantedBy=multi-user.target
runcmd:
- mkdir -p /home/${username}
- chown ${username}:${username} /home/${username}
- systemctl enable coder-agent
- systemctl start coder-agent
Loading