-
-
Save olivierlambert/0eff6d8c10dfb11e1f28efe66d37ce6f to your computer and use it in GitHub Desktop.
| 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"] | |
| } |
Awesome! That works! Thank you very much!
Thanks to @AtaxyaNetwork for the tip 😄
Hi @olivierlambert and Everyone else,
I am facing an issue.
I don't have DHCP server who can assign IP automatically.
So I am trying to use Static IP in my boot command like below to make internet available.
###########################################################
http_directory = "http"
ip_getter = "http"
boot_command = [
"",
"/install.amd/vmlinuz ",
"initrd=/install.amd/initrd.gz ",
"auto=true ",
Static networking required BEFORE fetching preseed (no DHCP available)
"netcfg/disable_autoconfig=true ",
"netcfg/disable_dhcp=true ",
"netcfg/choose_interface=auto ",
"netcfg/get_ipaddress=16x.1x.1xx.2xx ",
"netcfg/get_netmask=2xx.255.2xx.2xx ",
"netcfg/get_gateway=1xx.6x.x.x ",
"netcfg/get_nameservers=2xx.1xx.xx.xx ",
"netcfg/confirm_static=true ",
"domain= ",
"url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg ",
"hostname=debian ",
"interface=auto ",
"vga=788 noprompt quiet--- "
]
###########################################################
Same setting I have added in preseed file also.
But the issue is that my IP is binded to a MAC address. So I need to change the MAC address of newly created instance by packer also.
How I can achieve that? Any urgent help will be appreciated.
@chrispro-21 yes!
First, check that you have the SR name is defined:
Then, you can use
iso_name = "debian-12.5.0-amd64-netinst.iso"directly instead of the URL of the ISO.