Last active
April 24, 2025 10:30
-
-
Save olivierlambert/0eff6d8c10dfb11e1f28efe66d37ce6f to your computer and use it in GitHub Desktop.
Debian 12 generator for Packer on XCP-ng
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
packer { | |
required_plugins { | |
xenserver= { | |
version = "= v0.7.0" | |
source = "github.com/ddelnano/xenserver" | |
} | |
} | |
} | |
variable "remote_host" { | |
type = string | |
description = "The ip or fqdn of your XCP-ng. It must be the master" | |
sensitive = true | |
default = "10.10.1.66" | |
} | |
variable "remote_username" { | |
type = string | |
description = "The username used to interact with your XCP-ng" | |
sensitive = true | |
default = "root" | |
} | |
variable "remote_password" { | |
type = string | |
description = "The password used to interact with your XCP-ng" | |
sensitive = true | |
default = "P@ssw0rd" | |
} | |
variable "sr_iso_name" { | |
type = string | |
description = "The ISO-SR to packer will use" | |
default = "ISO Repository" | |
} | |
variable "sr_name" { | |
type = string | |
description = "The name of the SR to packer will use" | |
default = "Local storage" | |
} | |
source "xenserver-iso" "debian12" { | |
iso_checksum = "013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f" | |
iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso" | |
sr_iso_name = var.sr_iso_name | |
sr_name = var.sr_name | |
tools_iso_name = "" | |
remote_host = var.remote_host | |
remote_password = var.remote_password | |
remote_username = var.remote_username | |
http_directory = "http" | |
ip_getter = "tools" | |
boot_command = [ | |
"<wait><wait><wait><esc><wait><wait><wait>", | |
"/install.amd/vmlinuz ", | |
"initrd=/install.amd/initrd.gz ", | |
"auto=true ", | |
"domain= ", | |
"url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg ", | |
"hostname=debian ", | |
"interface=auto ", | |
"vga=788 noprompt quiet--- <enter>" | |
] | |
# Change this to match the ISO of ubuntu you are using in the iso_url variable | |
clone_template = "Debian Bookworm 12" | |
vm_name = "Debian 12 template" | |
vm_description = "My first template with packer" | |
vcpus_max = 2 | |
vcpus_atstartup = 2 | |
vm_memory = 2048 #MB | |
network_names = ["Private Lab"] | |
disk_size = 20480 #MB | |
disk_name = "debian disk" | |
vm_tags = ["Generated by Packer"] | |
ssh_username = "debian" | |
ssh_password = "debian" | |
ssh_wait_timeout = "60000s" | |
ssh_handshake_attempts = 10000 | |
output_directory = "packer-debian-12" | |
keep_vm = "never" | |
format = "xva_compressed" | |
} | |
build { | |
sources = ["xenserver-iso.debian12"] | |
} |
Is there support for a pre downloaded ISO already in a ISO SR?
@chrispro-21 yes!
First, check that you have the SR name is defined:
variable "sr_iso_name" {
type = string
default = "ISO Repository"
description = "The ISO-SR to packer will use"
}
Then, you can use iso_name = "debian-12.5.0-amd64-netinst.iso"
directly instead of the URL of the ISO.
Awesome! That works! Thank you very much!
Thanks to @AtaxyaNetwork for the tip 😄
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @olivierlambert for posting this. I'm using the same script to create a template through Packer and then through Terraform I want to create multiple VMs on xen-server. But I want to use two different disks (one for OS, one for APP data), so how can I define that? and should be defined in Packer script or Terraform script? Thanks