Compare commits
2 Commits
58af55e7e0
...
53e7fbd228
| Author | SHA1 | Date |
|---|---|---|
|
|
53e7fbd228 | |
|
|
7c0936d889 |
|
|
@ -116,7 +116,11 @@ power it off, switch boot order back to disk first, and run `qm template`.
|
||||||
The template sealing step discovers the installed VM IP through
|
The template sealing step discovers the installed VM IP through
|
||||||
qemu-guest-agent, so a DHCP reservation is no longer required for the temporary
|
qemu-guest-agent, so a DHCP reservation is no longer required for the temporary
|
||||||
template-build VM. If you still want to force a known address, set
|
template-build VM. If you still want to force a known address, set
|
||||||
`TF_VAR_pimox_template_build_host`.
|
`TF_VAR_pimox_template_build_host`. Leave it unset for the normal autodiscovery
|
||||||
|
path. Once a guest IP or explicit guest host is known, the seal step now uses a
|
||||||
|
shorter SSH deadline of `TF_VAR_pimox_template_guest_ssh_timeout_seconds=300`
|
||||||
|
by default so bad IP/SSH assumptions fail quickly instead of consuming the full
|
||||||
|
template build timeout.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./jeannie up
|
./jeannie up
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ resource "null_resource" "pimox_template_vm_seal" {
|
||||||
config_hash = local.config_hash
|
config_hash = local.config_hash
|
||||||
timeout = var.pimox_template_build_timeout
|
timeout = var.pimox_template_build_timeout
|
||||||
timeout_seconds = tostring(var.pimox_template_build_timeout_seconds)
|
timeout_seconds = tostring(var.pimox_template_build_timeout_seconds)
|
||||||
|
ssh_timeout_seconds = tostring(var.pimox_template_guest_ssh_timeout_seconds)
|
||||||
guest_ip_prefix = var.pimox_template_guest_ip_prefix
|
guest_ip_prefix = var.pimox_template_guest_ip_prefix
|
||||||
vmid = tostring(var.pimox_template_vmid)
|
vmid = tostring(var.pimox_template_vmid)
|
||||||
}
|
}
|
||||||
|
|
@ -279,6 +280,7 @@ guest_host="${self.triggers.guest_host}"
|
||||||
guest_user="${self.triggers.guest_user}"
|
guest_user="${self.triggers.guest_user}"
|
||||||
guest_key="${self.triggers.guest_key_path}"
|
guest_key="${self.triggers.guest_key_path}"
|
||||||
timeout_seconds="${self.triggers.timeout_seconds}"
|
timeout_seconds="${self.triggers.timeout_seconds}"
|
||||||
|
ssh_timeout_seconds="${self.triggers.ssh_timeout_seconds}"
|
||||||
guest_ip_prefix="${self.triggers.guest_ip_prefix}"
|
guest_ip_prefix="${self.triggers.guest_ip_prefix}"
|
||||||
vmid="${self.triggers.vmid}"
|
vmid="${self.triggers.vmid}"
|
||||||
|
|
||||||
|
|
@ -331,15 +333,38 @@ if ssh_pimox "sudo '$pimox_qm_bin' config '$vmid' | grep -q '^template: 1$'"; th
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ "$timeout_seconds" =~ ^[0-9]+$ ]] || [ "$timeout_seconds" -le 0 ]; then
|
||||||
|
echo "pimox_template_build_timeout_seconds must be a positive integer" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ "$ssh_timeout_seconds" =~ ^[0-9]+$ ]] || [ "$ssh_timeout_seconds" -le 0 ]; then
|
||||||
|
echo "pimox_template_guest_ssh_timeout_seconds must be a positive integer" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
deadline=$((SECONDS + timeout_seconds))
|
deadline=$((SECONDS + timeout_seconds))
|
||||||
|
ssh_deadline=0
|
||||||
next_log=$SECONDS
|
next_log=$SECONDS
|
||||||
while (( SECONDS < deadline )); do
|
while (( SECONDS < deadline )); do
|
||||||
if [ -z "$guest_host" ]; then
|
agent_ip="$(guest_ip_from_agent || true)"
|
||||||
guest_host="$(guest_ip_from_agent || true)"
|
if [ -n "$agent_ip" ]; then
|
||||||
|
if [ -n "$guest_host" ] && [ "$guest_host" != "$agent_ip" ]; then
|
||||||
|
echo "Configured template-build host $guest_host does not match qemu-guest-agent IP $agent_ip for VM $vmid." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$guest_host" ]; then
|
||||||
|
guest_host="$agent_ip"
|
||||||
|
ssh_deadline=$((SECONDS + ssh_timeout_seconds))
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$guest_host" ] && ssh_guest "test -x /usr/local/sbin/homelab-prepare-template.sh"; then
|
if [ -n "$guest_host" ] && ssh_guest "test -x /usr/local/sbin/homelab-prepare-template.sh"; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$guest_host" ] && (( ssh_deadline > 0 && SECONDS >= ssh_deadline )); then
|
||||||
|
echo "Timed out waiting for SSH on template-build VM $vmid at $guest_host after ${ssh_timeout_seconds}s once the guest host was known." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if (( SECONDS >= next_log )); then
|
if (( SECONDS >= next_log )); then
|
||||||
elapsed=$((timeout_seconds - (deadline - SECONDS)))
|
elapsed=$((timeout_seconds - (deadline - SECONDS)))
|
||||||
if [ -n "$guest_host" ]; then
|
if [ -n "$guest_host" ]; then
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,11 @@ variable "pimox_template_build_timeout_seconds" {
|
||||||
default = 3600
|
default = 3600
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "pimox_template_guest_ssh_timeout_seconds" {
|
||||||
|
type = number
|
||||||
|
default = 300
|
||||||
|
}
|
||||||
|
|
||||||
variable "pimox_template_guest_ip_prefix" {
|
variable "pimox_template_guest_ip_prefix" {
|
||||||
type = string
|
type = string
|
||||||
default = "192.168.100."
|
default = "192.168.100."
|
||||||
|
|
|
||||||
1
jeannie
1
jeannie
|
|
@ -191,7 +191,6 @@ export_homelab_inventory_tf_vars() {
|
||||||
export_if_unset TF_VAR_pimox_user "${LAB_PIMOX_USER:-}"
|
export_if_unset TF_VAR_pimox_user "${LAB_PIMOX_USER:-}"
|
||||||
export_if_unset TF_VAR_pimox_worker_storage "${LAB_PIMOX_WORKER_STORAGE:-}"
|
export_if_unset TF_VAR_pimox_worker_storage "${LAB_PIMOX_WORKER_STORAGE:-}"
|
||||||
export_if_unset TF_VAR_pimox_template_bridge "${LAB_PIMOX_BRIDGE:-}"
|
export_if_unset TF_VAR_pimox_template_bridge "${LAB_PIMOX_BRIDGE:-}"
|
||||||
export_if_unset TF_VAR_pimox_template_build_host "${LAB_DEBIAN_LAN_IP:-}"
|
|
||||||
export_if_unset TF_VAR_pimox_template_build_user "${LAB_DEBIAN_USER:-}"
|
export_if_unset TF_VAR_pimox_template_build_user "${LAB_DEBIAN_USER:-}"
|
||||||
export_if_unset TF_VAR_pimox_template_guest_ip_prefix "${LAB_LAN_IP_PREFIX:-}"
|
export_if_unset TF_VAR_pimox_template_guest_ip_prefix "${LAB_LAN_IP_PREFIX:-}"
|
||||||
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
|
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue