iTranslated by AI
Proxmox Automated Provisioning for Homelabs Part 1: From Custom ISO Generation to Node Discovery and Static IP Assignment
Overview
I have built an Ansible-based system to deploy Proxmox VE nodes in my home lab with minimal manual intervention.
-
Automated Custom ISO Generation: Create auto-install ISOs embedded with
answer.tomlusing Ansible. - Node Discovery and UUID Verification: Scan the network to discover nodes that booted via DHCP and match them with inventory using their UUIDs.
- Automatic Static IP and Hostname Configuration: Set static IPs and hostnames based on the verification results to make the node ready for production.
The only manual operation required is the single step of "booting from the ISO."
Background
I operate multiple Proxmox VE nodes in my home lab. Sometimes, I need to reinstall Proxmox VE from scratch for testing purposes. Each time I do, I am faced with the following manual tasks:
- Start the installer from an ISO and select keyboard layout and time zone settings.
- Enter network configuration details.
- Set the hostname and static IP after installation completes.
- Issue certificates, configure repositories, set up storage, etc.
This is not much trouble for a single machine, but the manual workload adds up as the number of nodes increases or when reinstallation is repeated.
The ideal approach is Zero-Touch Provisioning (ZTP). While this is achieved in enterprise environments using PXE boot or MAAS (Metal as a Service), building a DHCP/TFTP server or deploying MAAS is too heavy for a home lab scale.
This led me to the automatic installation feature introduced in Proxmox VE 8.1 and later. By using the CLI tool proxmox-auto-install-assistant, you can embed an answer file (answer.toml) into an ISO. This allows you to skip the interactive installer steps. Combining this with Ansible, I have automated everything except for "burning the ISO and booting it."
Overall Architecture
The deployment flow consists of the following 4 steps:
-
ISO Build ── Generate a custom ISO with
answer.tomlembedded usingansible-playbook playbooks/build_iso.yml. - ISO Boot (Only manual step) ── Start the physical machine from the ISO to perform an automatic Proxmox VE installation. The node will be connected via DHCP.
-
Bootstrap ── Execute the following 3 phases using
ansible-playbook playbooks/bootstrap.yml:- Phase 1: Discovery ── Discover DHCP nodes via network scanning.
- Phase 2: Identification ── Match nodes with the inventory using UUID/serial.
- Phase 3: Configuration ── Set static IP and hostname, then reboot.
-
Day 2 Configuration ── Configure clusters, repositories, certificates, and VIPs using
ansible-playbook playbooks/configure_proxmox.yml.
The project structure is as follows (source code is available via the link in the overview section).
.
├── filter_plugins/ # Custom filters (IP range expansion)
├── inventory/ # Network and host definitions
│ └── test/
│ ├── credentials/ # Environment-specific SSH keys
│ ├── hosts.yml # Host definitions (UUID/IP/hostname)
│ └── group_vars/all.yml
├── playbooks/
│ ├── build_iso.yml # ISO build
│ ├── bootstrap.yml # Initial setup (3 phases)
│ └── configure_proxmox.yml # Day 2 configuration
└── roles/
├── iso_builder/ # ISO creation role
└── bootstrap/ # Discovery and configuration role
Prerequisites and Environment
- Proxmox VE: 9.1 (based on Debian bookworm)
- Ansible: 2.15 or later
- Control Node: The machine running Ansible (Linux / macOS)
- Target Nodes: Physical machines to install Proxmox VE onto
- Network: The control node and target nodes must be on the same L2 network
- DHCP Server: The target nodes must be able to acquire an IP via DHCP (standard home routers are fine)
Preparation: Inventory Definition
First, define the target nodes in the inventory. A key feature of this design is that nodes are individually identified by their UUID (SMBIOS product_uuid).
all:
hosts:
pve-01:
ansible_host: "172.16.1.11"
proxmox_ip: "172.16.1.11"
proxmox_smbios_id: "5b05f981-d568-47fe-bdca-0015221dee0f"
proxmox_hostname: "pve01"
proxmox_gateway: "172.16.1.1"
proxmox_network_interface: "ens18"
The role of each variable is as follows:
| Variable | Description |
|---|---|
ansible_host / proxmox_ip
|
The static IP to assign finally |
proxmox_smbios_id |
Node UUID (motherboard-specific value) |
proxmox_hostname |
Hostname to set |
proxmox_gateway |
Default gateway |
proxmox_network_interface |
Physical NIC interface name |
In the group variables, define DHCP scanning ranges and common network settings.
proxmox_root_password: "Passw0rd!"
bootstrap_dhcp_network: "172.16.1.0/24"
bootstrap_dhcp_range: "172.16.1.64-72"
proxmox_keyboard: "jp"
proxmox_timezone: "Asia/Tokyo"
proxmox_netmask: "255.255.255.0"
proxmox_dns: "1.1.1.1"
bootstrap_dhcp_range is the IP range to scan during bootstrapping. Set this according to your DHCP server's lease range.
Step 1: Building the Auto-Install ISO
The ISO build is performed using playbooks/build_iso.yml.
ansible-playbook -i localhost, playbooks/build_iso.yml -K \
-e "proxmox_root_password=YourPassword"
This playbook calls the iso_builder role and performs the following operations:
- Download the official Proxmox VE ISO.
- Install
proxmox-auto-install-assistantandxorriso. - Generate
answer.tomlfrom a template. - Create a custom ISO with the embedded answer file.
Structure of answer.toml
answer.toml is the response file referenced by the Proxmox auto-installer. All interactive installer operations (keyboard, timezone, password, etc.) are defined in this file.
[global]
keyboard = "jp"
country = "jp"
fqdn = "proxmox.local"
mailto = "admin@example.com"
timezone = "Asia/Tokyo"
root-password = "{{ proxmox_root_password }}" # Replaced by Ansible template
root-ssh-keys = [
"{{ proxmox_ssh_keys[0] }}" # Embeds the control node's SSH public key
]
reboot-mode = "reboot"
[network]
source = "from-dhcp"
[disk-setup]
filesystem = "ext4"
disk-list = ["sda"]
In the [network] section, source = "from-dhcp" is specified. During the initial installation, a static IP is not yet set; instead, a temporary IP is acquired via DHCP. Static IP configuration is handled in the bootstrap phase.
root-ssh-keys embeds the control node's SSH public key, allowing SSH access without password authentication immediately after installation.
ISO Generation Command
proxmox-auto-install-assistant rewrites the ISO.
proxmox-auto-install-assistant prepare-iso \
<source_iso> \
--fetch-from iso \
--answer-file <answer.toml> \
--output <output_iso>
--fetch-from iso specifies the method to embed the answer file directly into the ISO. While methods like --fetch-from http (to retrieve from an HTTP server) exist, embedding in the ISO is the simplest approach for home labs.
Step 2: Installation from ISO
Write the generated custom ISO to a USB flash drive and boot the physical machine from it. This is the only manual step.
Unlike the standard installer, all settings are applied automatically based on answer.toml. Screens for keyboard selection or disk selection do not appear, and the system reboots automatically once the installation is complete.
After rebooting, the node will be accessible via SSH with an IP address acquired via DHCP.
Step 3: Bootstrapping
Bootstrapping is performed using playbooks/bootstrap.yml. It consists of three phases (Discovery, Identification, and Configuration).
ansible-playbook -i inventory/test/ playbooks/bootstrap.yml
Phase 1: Discovery
The IP address of the node that booted via DHCP is not yet known. In Phase 1, we scan the specified IP range to search for hosts with the SSH port (port 22) open.
- name: "Phase 1: Discovery"
hosts: localhost
connection: local
tasks:
- name: "Include discovery tasks"
include_role:
name: bootstrap
tasks_from: discovery.yml
- name: "Add discovered IPs to temporary group"
add_host:
name: "{{ item }}"
groups: discovered_group
loop: "{{ candidate_nodes | default([]) }}"
We use a custom filter plugin to expand the IP range. It converts range specifications like 172.16.1.64-72 into a list of IP addresses.
import netaddr
class FilterModule(object):
def filters(self):
return {'generate_ips': self.generate_ips}
def generate_ips(self, ip_input):
"""
Converts CIDR (e.g., 192.168.1.0/24) or range specifications (e.g., 192.168.1.10-20)
into a list of IP addresses.
"""
if '-' in ip_input:
# "192.168.1.10-20" → start="192.168.1.10", end="192.168.1.20"
parts = [p.strip() for p in ip_input.split('-')]
start_str = parts[0]
end_str = parts[1]
# If in shorthand, complete the prefix of the end IP
if '.' not in end_str:
prefix = '.'.join(start_str.split('.')[:-1])
end_str = f"{prefix}.{end_str}"
return [str(ip) for ip in netaddr.IPRange(start_str, end_str)]
else:
return [str(ip) for ip in netaddr.IPNetwork(ip_input).iter_hosts()]
Port scanning is performed in parallel using Python's concurrent.futures. With a setting of 50 workers and a 0.5-second timeout, the entire /24 network can be scanned in just a few seconds.
- name: "Scan IPs for port 22 (Parallel)"
shell: |
python3 -c "
import socket
from concurrent.futures import ThreadPoolExecutor
def check(ip):
try:
with socket.create_connection((ip, 22), timeout=0.5):
return ip
except:
return None
ips = '{{ ips_to_scan | join(',') }}'.split(',')
with ThreadPoolExecutor(max_workers=50) as e:
results = e.map(check, ips)
print(','.join([r for r in results if r]))
"
delegate_to: localhost
Phase 2: Identification
We connect via SSH to the IPs discovered in Phase 1 and collect ansible_facts. At this stage, we log in using password authentication via ansible_ssh_pass (using the root password set in answer.toml).
- name: "Phase 2: Identification"
hosts: discovered_group
gather_facts: no
ignore_unreachable: yes
tasks:
- name: "Gather facts from discovered nodes"
setup:
vars:
ansible_user: "root"
ansible_ssh_pass: "{{ proxmox_root_password | default('') }}"
We specify gather_facts: no but explicitly call the setup module. Since discovered_group is dynamically created via add_host and authentication information is not defined in the inventory, we disable implicit facts gathering and call setup explicitly to pass the password via task-level vars.
ignore_unreachable: yes is used to skip hosts that cannot be connected. The IP list discovered in Phase 1 might include hosts other than Proxmox nodes (e.g., existing servers).
The ansible_facts collected in this phase contain the product_uuid (SMBIOS UUID), which is used to match against the inventory in the next phase.
Phase 3: Configuration
We match the product_uuid collected in Phase 2 with the proxmox_smbios_id defined in the inventory and configure the static IP and hostname for the matched nodes.
- name: "Phase 3: Configuration"
hosts: "all:!discovered_group:!localhost"
tasks:
- name: "Match UUID and assign ansible_host"
set_fact:
ansible_host: "{{ item }}"
node_identified: yes
loop: "{{ groups['discovered_group'] | default([]) }}"
when:
- proxmox_smbios_id is defined
- hostvars[item].ansible_facts.get('product_uuid') == proxmox_smbios_id or
hostvars[item].ansible_facts.get('product_serial') == proxmox_smbios_id
- name: "Run configuration for matched hosts"
include_role:
name: bootstrap
tasks_from: configure_host.yml
when: node_identified | bool
hosts: "all:!discovered_group:!localhost" targets hosts defined in the inventory (like pve-01), excluding the discovered_group (DHCP IPs found in Phase 1) and localhost.
We check both product_uuid and product_serial for UUID matching, as hardware sometimes stores the UUID in different fields.
Details of configure_host.yml
For nodes where the UUID matches, the following settings are applied sequentially:
- Set hostname
- Update
/etc/hosts - Set static IP (applying the
/etc/network/interfacestemplate) - Deploy environment-specific SSH public keys (adding operational keys separate from the ones embedded in
answer.toml) - Reboot to apply network settings
- Verify SSH connection with the new IP (with up to 5 retries)
The network template configures the standard Proxmox Linux Bridge (vmbr0).
auto lo
iface lo inet loopback
iface {{ proxmox_network_interface | default('enp0s1') }} inet manual
auto vmbr0
iface vmbr0 inet static
address {{ proxmox_ip }}
netmask {{ proxmox_netmask | default('255.255.255.0') }}
gateway {{ proxmox_gateway }}
bridge-ports {{ proxmox_network_interface | default('enp0s1') }}
bridge-stp off
bridge-fd 0
A reboot is required after changing network settings. Since the connection switches from a DHCP IP to a static IP, SSH connectivity is verified using the new IP address after the reboot.
Verification
After bootstrapping is complete, verify the following:
# Confirm SSH connection via static IP
ssh root@172.16.1.11
# Confirm hostname is set correctly
hostname # → pve01
# Confirm access to Proxmox Web UI
# Open https://172.16.1.11:8006 in a browser
Up to this point, all operations other than ISO booting have been automated.
To proceed with Day 2 configuration, run configure_proxmox.yml.
ansible-playbook -i inventory/test/ playbooks/configure_proxmox.yml
Troubleshooting Points
[network] Section in answer.toml
Initially, I attempted to specify the static IP directly in answer.toml. However, the automated installer's answer.toml does not provide a way to specify different IPs for different nodes (only one answer.toml can be embedded per ISO). Therefore, I adopted a two-stage approach: booting via DHCP first, then configuring the static IP during the bootstrap phase.
UUID Source Field
The UUID returned by the Ansible setup module may be stored in product_uuid or product_serial depending on the hardware. Initially, I only matched against product_uuid, which caused some machines to fail matching. This was resolved by modifying the script to check both fields.
Timing of Port Scan
After installation from the ISO completes, it takes several minutes (including a reboot) for the node to be ready for SSH connections. If bootstrapping is executed too early, Phase 1 will fail to find the nodes. It must be executed only after the node has finished rebooting.
Summary
By combining Proxmox VE's auto-installation feature with Ansible, I minimized manual operations to a single step: "boot from ISO."
-
ISO Build: Custom ISOs with embedded
answer.tomlare automatically generated usingproxmox-auto-install-assistant. - Bootstrap: Using a three-phase approach (network scan → UUID matching → static IP configuration), nodes in a DHCP state are automatically converted to the configuration defined in the inventory.
- Individual Identification: By using SMBIOS UUID, nodes that acquire random IPs via DHCP can be reliably matched to the inventory.
This approach is well-suited for a home lab scale as it does not require separate infrastructure like PXE or MAAS, and can be completed using only an existing DHCP server (e.g., home router) and Ansible.
Discussion