Compare commits

...
18 Commits
Author SHA1 Message Date
VezpiandHermes Agent 2ae0b7a61b Feat/proxmox vm cpu baseline (#10)
Co-authored-by: Hermes Agent <hermes@vezpi.com>
Reviewed-on: #10
2026-11-24 10:15:03 +01:00
Vezpi fff1434331 update(homeassistant): 2026.10 2026-11-21 10:08:26 +01:00
Vezpi 37cc21e450 change(ansible): wait DNS delay 2026-11-11 21:10:52 +00:00
Vezpi c53a59e60a add(ansible): cloud init status message 2026-11-11 21:10:04 +00:00
Hermes Agent 9557b37603 docs(proxmox): clarify VM provisioning instructions 2026-11-10 17:35:46 +00:00
Hermes Agent d019088f6a fix(ansible): remove guest agent virtio channel check 2026-11-10 17:29:45 +00:00
Hermes Agent 53f4d27601 feat(ansible): provision QEMU guest agent on new clones 2026-11-10 16:06:21 +00:00
Vezpi 5148019f9d add(terraform): semaphore ssh key 2026-11-09 14:49:49 +00:00
VezpiandHermes Agent 5222e6cd6c feat(ansible): vm provision ansible (#9)
Co-authored-by: Hermes Agent <hermes@vezpi.com>
Reviewed-on: #9
2026-11-09 15:46:14 +01:00
Vezpi 843d1bda63 remove(cloudinit): serial display 2026-11-09 14:35:19 +00:00
Vezpi 6927c98e01 change(cloudinit): default network to vlan66 2026-11-08 22:25:02 +00:00
Vezpi f1c2852bf4 update(gitea): v28 2026-11-02 22:01:03 +01:00
Vezpi 0b57391c38 update(unifi): 10.6.109-ls152 2026-11-02 21:49:50 +01:00
Vezpi 2f60045469 update(unifi): v10.6.106-ls146 2026-11-02 21:43:13 +01:00
Hermes Agent 1325775404 docs(kubernetes): document cluster bootstrap and networking 2026-11-01 21:54:04 +00:00
Vezpi dddeca41d4 update(nextcloud): v35 2026-11-01 22:26:29 +01:00
Vezpi 14a9feb28a update(nextcloud): v34 2026-11-01 22:12:22 +01:00
Vezpi 88dba7dcd9 update(nextcloud): v33 2026-10-29 22:43:02 +01:00
11 changed files with 310 additions and 11 deletions

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
# Provision one Proxmox VM with Semaphore
Run `ansible/proxmox/provision_vm.yml` as a Semaphore Ansible task with inventory `localhost ansible_connection=local`. It clones one cloud-init template, configures the new VM before boot, then connects to the guest by FQDN.
## Prerequisites
- The template needs a bootable `scsi0`, a `scsi1` cloud-init drive, Python 3, `cloud-init`, `timeout`, SSH and network access. It does not need the QEMU guest agent enabled.
- The guest needs `timedatectl`, `tzdata`, apt access and noninteractive sudo for `vm_user` to set its timezone and install/start the agent.
- The Semaphore runner must trust the Proxmox CA and have a verified guest SSH host key in `known_hosts`. Do not disable TLS or SSH host-key verification. Confirm the DNS record belongs to the new VM before connecting; a stale record could point to another host.
- Select an SSH Key Store **user credential on the task inventory** matching an authorized public key for `vm_user`. Check that the same invocation makes this credential available to the dynamically added guest in your installed Semaphore version. The Proxmox API token is separate.
- The Semaphore image installs `proxmoxer>=2.3,<3` and `requests>=2.31,<3` from `docker/semaphore/requirements.txt` on startup (mounted at `/etc/semaphore/requirements.txt`). Semaphore installs `ansible/proxmox/requirements.yml` (`community.proxmox:2.0.0`) unless **Skip Galaxy install** is enabled.
## Semaphore variables
Put these fixed values in a Variable Group:
| Variable | Value |
| --- | --- |
| `proxmox_api_host` | Hostname, not a URL |
| `vm_template_id`, `vm_storage`, `vm_user` | Template, destination storage and guest user |
| `vm_ssh_public_key` | One or more complete public keys, separated by newlines; include the key matching the selected SSH credential |
| `proxmox_api_port` | Optional; defaults to `8006` |
| `vm_ipconfig0` | Optional; defaults to `ip=dhcp` |
Put `proxmox_api_token_id` (full `user@realm!token`) and `proxmox_api_token_secret` in the Variable Group's **Secrets** tab, not the survey.
Survey inputs:
| Variable | Default |
| --- | --- |
| `vm_hostname` | Required unique short DNS label (no dots) |
| `vm_cpu` | `1` core |
| `vm_ram_gib` | `2` GiB |
| `vm_disk_gib` | `4` GiB, absolute disk size |
| `vm_vlan` | `vlan66` bridge/VNet name |
Only `vlan66` maps to a DNS suffix (`lab.vezpi.com`); other VLANs fail before cloning. DHCP/DNS must publish `<hostname>.lab.vezpi.com` for that VNet.
## What happens
1. The playbook rejects an invalid or existing hostname, then finds the template's current node and clones it. It enables the clone's virtio guest-agent channel before first boot, regardless of template configuration.
2. It waits for DNS, port 22, an Ansible connection and cloud-init. Cloud-init exit code `0` is accepted; degraded exit code `2` is accepted with a warning. Other codes, incomplete status and timeouts fail.
3. On the guest it sets the display timezone to `Europe/Paris` (CET/CEST), installs `qemu-guest-agent` and starts its device-activated service. It does not change RTC/NTP, manually enable the static unit, configure sudo or reboot.
New clones use `vm_cpu_model` (default `x86-64-v2-AES`, overridable via extra vars) before first boot; every destination host must support the selected model. Existing VMs and templates are unchanged.
A failure leaves the new VM intact for inspection. Playbook success does **not** prove agent communication: on the VM's actual Proxmox node, run `qm agent <NEW_VMID> ping`. A successful exit with no error is sufficient, even if the response is empty.
+1 -4
View File
@@ -82,7 +82,7 @@
qm create {{ template_vmid }} qm create {{ template_vmid }}
--memory {{ template_memory }} --memory {{ template_memory }}
--core {{ template_cores }} --core {{ template_cores }}
--net0 virtio,bridge=vmbr0 --net0 virtio,bridge=vlan66
--scsihw virtio-scsi-pci --scsihw virtio-scsi-pci
--bios ovmf --bios ovmf
--machine q35 --machine q35
@@ -98,9 +98,6 @@
- name: Set boot order to the primary disk - name: Set boot order to the primary disk
ansible.builtin.command: qm set {{ template_vmid }} --boot order=scsi0 ansible.builtin.command: qm set {{ template_vmid }} --boot order=scsi0
- name: Add serial console for cloud-init consoles
ansible.builtin.command: qm set {{ template_vmid }} --serial0 socket --vga serial0
- name: Convert the VM to a template - name: Convert the VM to a template
ansible.builtin.command: qm template {{ template_vmid }} ansible.builtin.command: qm template {{ template_vmid }}
+192
View File
@@ -0,0 +1,192 @@
---
- name: Clone and start one cloud-init VM
hosts: localhost
connection: local
gather_facts: false
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
vm_cpu: 1
vm_cpu_model: x86-64-v2-AES
vm_ram_gib: 2
vm_disk_gib: 4
vm_vlan: vlan66
vm_ipconfig0: ip=dhcp
vm_dns_domains:
vlan66: lab.vezpi.com
module_defaults:
group/community.proxmox.proxmox:
api_host: "{{ proxmox_api_host }}"
api_port: "{{ proxmox_api_port | default(8006) }}"
api_user: "{{ proxmox_api_token_id.split('!')[0] }}"
api_token_id: "{{ proxmox_api_token_id.split('!')[1] }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
validate_certs: true
tasks:
- name: Validate hostname and DNS mapping before using the API
ansible.builtin.assert:
that:
- vm_hostname is defined and vm_hostname is match('^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$')
- vm_vlan in vm_dns_domains
fail_msg: A short hostname and a known VLAN/DNS suffix are required; no VM was created.
- name: Look up requested hostname across the cluster
community.proxmox.proxmox_vm_info:
name: "{{ vm_hostname }}"
register: named_vm
no_log: true
- name: Reject an already used hostname
ansible.builtin.assert:
that: named_vm.proxmox_vms | length == 0
fail_msg: "Hostname {{ vm_hostname }} already exists; no VM was modified. Inspect it before retrying."
- name: Look up source template and its current configuration
community.proxmox.proxmox_vm_info:
vmid: "{{ vm_template_id }}"
type: qemu
config: current
register: source_vm
no_log: true
- name: Require a cloud-init-ready template on its current node
ansible.builtin.assert:
that:
- source_vm.proxmox_vms | length == 1
- source_vm.proxmox_vms[0].node is defined
- source_vm.proxmox_vms[0].template | bool
- source_vm.proxmox_vms[0].config.scsi0 is defined
- source_vm.proxmox_vms[0].config.scsi1 is defined
- "'cloudinit' in source_vm.proxmox_vms[0].config.scsi1"
fail_msg: "Template {{ vm_template_id }} must resolve uniquely to a QEMU template with a node, scsi0 and a scsi1 cloud-init drive; no VM was created."
- name: Clone template into a new VM
community.proxmox.proxmox_kvm:
clone: source-template
vmid: "{{ vm_template_id }}"
name: "{{ vm_hostname }}"
node: "{{ source_vm.proxmox_vms[0].node }}"
storage: "{{ vm_storage }}"
full: true
state: present
register: cloned_vm
no_log: true
- name: Stop if cloning did not allocate a new VMID
ansible.builtin.assert:
that:
- cloned_vm.changed
- cloned_vm.vmid is defined
- cloned_vm.vmid | int != vm_template_id | int
fail_msg: >-
Clone did not return a valid new VMID (possibly allocated concurrently);
no configuration was attempted. Inspect the cluster before retrying.
- name: Configure VM before first boot
community.proxmox.proxmox_kvm:
vmid: "{{ cloned_vm.vmid }}"
node: "{{ source_vm.proxmox_vms[0].node }}"
update: true
update_unsafe: true # Needed to replace net0 on this newly cloned VM.
cores: "{{ vm_cpu }}"
cpu: "{{ vm_cpu_model }}"
memory: "{{ vm_ram_gib | int * 1024 }}"
net:
net0: "virtio,bridge={{ vm_vlan }}"
ipconfig:
ipconfig0: "{{ vm_ipconfig0 }}"
ciuser: "{{ vm_user }}"
sshkeys: "{{ vm_ssh_public_key }}"
agent: "enabled=1,type=virtio"
state: present
no_log: true
- name: Resize VM disk to requested size
community.proxmox.proxmox_disk:
vmid: "{{ cloned_vm.vmid }}"
disk: scsi0
size: "{{ vm_disk_gib }}G"
state: resized
no_log: true
- name: Start VM
community.proxmox.proxmox_kvm:
vmid: "{{ cloned_vm.vmid }}"
state: started
no_log: true
- name: Wait for guest DNS publication
ansible.builtin.command: getent ahosts "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
register: guest_dns
changed_when: false
until: guest_dns.rc == 0 and guest_dns.stdout | length > 0
retries: 20
delay: 15
- name: Wait for guest SSH port
ansible.builtin.wait_for:
host: "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
port: 22
connect_timeout: 5
timeout: 180
sleep: 5
- name: Add VM to dynamic inventory
ansible.builtin.add_host:
name: "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
groups: provisioned_vm
ansible_connection: ssh
ansible_user: "{{ vm_user }}"
ansible_ssh_timeout: 10
provisioned_vmid: "{{ cloned_vm.vmid }}"
- name: Verify cloud-init and Ansible on the new guest
hosts: provisioned_vm
gather_facts: false
vars:
vm_timezone: Europe/Paris
tasks:
- name: Wait for guest to be available
ansible.builtin.wait_for_connection:
connect_timeout: 10
sleep: 5
timeout: 180
- name: Wait for cloud-init status
ansible.builtin.command: timeout 300 cloud-init status --wait --long
register: cloudinit_wait
changed_when: false
failed_when: false
- name: Show cloud-init wait diagnostics
ansible.builtin.debug:
msg:
- "stdout: {{ cloudinit_wait.stdout | trim }}"
- "stderr: {{ cloudinit_wait.stderr | trim }}"
when: cloudinit_wait.rc == 2
- name: Assert cloud-init completion
ansible.builtin.assert:
that:
- cloudinit_wait.rc in [0, 2]
- "cloudinit_wait.stdout is search('(?m)^status: done\\s*$')"
fail_msg: "VMID {{ provisioned_vmid }} cloud-init status is not complete (rc {{ cloudinit_wait.rc }}); VM left intact for inspection."
- name: Set guest timezone
ansible.builtin.command: timedatectl set-timezone "{{ vm_timezone }}"
become: true
- name: Install QEMU guest agent
ansible.builtin.apt:
name: qemu-guest-agent
state: present
become: true
- name: Start QEMU guest agent
ansible.builtin.service:
name: qemu-guest-agent
state: started
become: true
- name: Report verified guest readiness
ansible.builtin.debug:
msg: "VMID {{ provisioned_vmid }} at {{ inventory_hostname }} completed cloud-init."
+4
View File
@@ -0,0 +1,4 @@
---
collections:
- name: community.proxmox
version: "2.0.0"
+1 -1
View File
@@ -1,6 +1,6 @@
services: services:
server: server:
image: gitea/gitea:1.27 image: gitea/gitea:28
container_name: gitea_server container_name: gitea_server
restart: always restart: always
volumes: volumes:
+1 -1
View File
@@ -1,6 +1,6 @@
services: services:
homeassistant: homeassistant:
image: homeassistant/home-assistant:2026.9 image: homeassistant/home-assistant:2026.10
container_name: homeassistant_core container_name: homeassistant_core
hostname: homeassistant_core hostname: homeassistant_core
volumes: volumes:
+2 -2
View File
@@ -23,7 +23,7 @@ services:
restart: always restart: always
core: core:
image: nextcloud:32-fpm-alpine image: nextcloud:35-fpm-alpine
container_name: nextcloud_core container_name: nextcloud_core
volumes: volumes:
- /appli/data/nextcloud/data:/var/www/html - /appli/data/nextcloud/data:/var/www/html
@@ -66,7 +66,7 @@ services:
restart: always restart: always
cron: cron:
image: nextcloud:32-fpm-alpine image: nextcloud:35-fpm-alpine
container_name: nextcloud_cron container_name: nextcloud_cron
volumes: volumes:
- /appli/data/nextcloud/data:/var/www/html - /appli/data/nextcloud/data:/var/www/html
+2 -1
View File
@@ -1 +1,2 @@
proxmoxer>=2.3 proxmoxer>=2.3,<3
requests>=2.31,<3
+1 -1
View File
@@ -1,6 +1,6 @@
services: services:
network_application: network_application:
image: lscr.io/linuxserver/unifi-network-application:10.6.101-ls143 image: lscr.io/linuxserver/unifi-network-application:10.6.109-ls152
container_name: unifi_network_application container_name: unifi_network_application
depends_on: depends_on:
- db - db
+57
View File
@@ -0,0 +1,57 @@
# Kubernetes
## Overview
The lab inventory records six Kubernetes VMs on Proxmox: three control-plane nodes with stacked etcd and three workers. Kubernetes and Cilium are deployed, with worker BGP sessions to OPNsense recorded as established. No application workloads are deployed. This describes the documented state, not a live verification.
Terraform provisions the VMs, Ansible prepares the nodes, and bootstrap and initial component installation are manual. Background: [migration roadmap](https://blog.vezpi.com/en/post/roadmap-migrate-docker-applications-kubernetes/).
## Prerequisites
1. Provision the VMs with the [Terraform Kubernetes VMs documentation](../terraform/projects/kubernetes_vms/README.md).
2. Prepare all nodes with the [Ansible Kubernetes nodes documentation](../ansible/kubernetes/README.md). It configures swap, kernel settings, containerd, Kubernetes packages and the host firewall, but does not run `kubeadm init` or `kubeadm join`. Review the [Ansible defaults](../ansible/kubernetes/roles/k8s_node/defaults/main.yml) and adapt inventory paths and firewall ranges, including Cilium and BGP traffic.
3. Provide working node DNS and a stable API DNS endpoint on TCP port `6443`; the lab uses HAProxy on OPNsense across the control-plane nodes.
4. Install `kubectl` and the Cilium CLI on the administration machine, and check the intended cluster context. Keep credentials, kubeconfigs, join tokens and Terraform state out of Git.
Walkthrough: [Automating Kubernetes VM Deployment with Terraform and Ansible](https://blog.vezpi.com/en/post/automate-kubernetes-vms-terraform-ansible/).
## Cluster bootstrap: kubeadm
For a **new, prepared cluster**, initialize the first control-plane node with the target API DNS name and a non-overlapping pod CIDR:
```text
sudo kubeadm init \
--control-plane-endpoint "<API_DNS>:6443" \
--upload-certs \
--pod-network-cidr=<POD_CIDR>
```
Configure `kubectl` using the generated admin kubeconfig. Join the remaining nodes with freshly generated commands: include `--control-plane` and `--certificate-key` for additional control planes, but not workers. Install Cilium below; nodes can remain `NotReady` until the CNI works.
Walkthrough: [Create a Highly Available Kubernetes Cluster with kubeadm on VMs](https://blog.vezpi.com/en/post/create-manual-kubernetes-cluster-kubeadm/). Its names, versions and firewall shortcuts are historical; use the Ansible preparation above rather than disabling the firewall.
**Installation caveat:** these historical commands are not a tested, reproducible rebuild procedure or instructions to reinstall the existing cluster. Exact Kubernetes package builds are unpinned; the historical CLI installer uses a moving `stable.txt`, and `cilium install` omits `--version`.
## Networking: Cilium
### CNI and pod connectivity
Cilium provides pod networking. The [bootstrap walkthrough](https://blog.vezpi.com/en/post/create-manual-kubernetes-cluster-kubeadm/) covers its checksum-verified, architecture-specific CLI download and connectivity testing; it predates this cluster's BGP setup.
The recorded fresh-cluster installation enables the BGP control plane:
```bash
cilium install --set bgpControlPlane.enabled=true
cilium status --wait
kubectl get nodes
```
Check for healthy Cilium components and all six nodes `Ready`. The optional `cilium connectivity test` exercises pod networking and DNS but creates temporary workloads; run only with approval and account for cleanup.
### BGP
Cilium peers with OPNsense FRR to advertise service `LoadBalancerIP` addresses. The recorded configuration uses `CiliumBGPPeerConfig` for peer settings and advertisement selection, `CiliumBGPClusterConfig` for worker selection and peering, and `CiliumBGPAdvertisement` for service advertisements.
The setup pairs FRR/BGP and firewall access on OPNsense with worker labels and matching peer settings and advertisement labels. Check sessions with `cilium bgp peers`; worker sessions are recorded as established, but that alone does not prove LoadBalancer address allocation, advertisement or reachability.
**BGP service exposure: ongoing.**
+2 -1
View File
@@ -31,7 +31,8 @@ variable "vm_user_sshkeys" {
type = list(string) type = list(string)
default = [ default = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID62LmYRu1rDUha3timAIcA39LtcIOny1iAgFLnxoBxm vez@bastion", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID62LmYRu1rDUha3timAIcA39LtcIOny1iAgFLnxoBxm vez@bastion",
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHovfHKpqTvwj5zrcSuSZALa8iiH6qBvE5dyJCz9eQ2k vez@surface" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHovfHKpqTvwj5zrcSuSZALa8iiH6qBvE5dyJCz9eQ2k vez@surface",
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG9bx04oxnZTmMm/7U9lUlhZM64xIMUSx48JiwxUH86x semaphore"
] ]
} }