Hi all,
I have been trying all day to set up a ci/cd pipeline to build images with packer for my proxmox node. I have used this post as a reference along with the proxmox packer documentation. Packer Ubuntu 20.04 autoinstall via CD drive.
I would use the http server but my gitlab runner is on a kubernetes cluster. I thought maybe building a custom instance of the packer image as an option but this seems much simpler. I am positive my issue is in my pkr.hcl file and was hoping someone here would enlighten me. Thank you in advance. The error I receive when I run my pipeline job is
`Error: Unsupported argument` ` on ubuntu-server-jammy.pkr.hcl line 76:` ` (source code not available)` `An argument named "cd_files" is not expected here`
Here is my hcl file
# Ubuntu Server jammy
# ---
# Packer Template to create an Ubuntu Server (jammy) on Proxmox
# Variable Definitions
# Resource Definiation for the VM Template
source "proxmox" "ubuntu-server-jammy" {
# Proxmox Connection Settings
proxmox_url = var.proxmox_api_url
username = var.proxmox_api_token_id
token = var.proxmox_api_token_secret
# (Optional) Skip TLS Verification
insecure_skip_tls_verify = true
# VM General Settings
node = "hv1"
vm_id = "9006"
vm_name = "Hashi-ubuntu-server-jammy-1"
template_description = "Hashistack"
# VM OS Settings
# (Option 1) Local ISO File
# iso_file = "local:iso/ubuntu-22.04-live-server-amd64.iso"
# - or -
# (Option 2) Download ISO
iso_url = "https://releases.ubuntu.com/22.04/ubuntu-22.04.1-live-server-amd64.iso"
iso_checksum = "10f19c5b2b8d6db711582e0e27f5116296c34fe4b313ba45f9b201a5007056cb"
iso_storage_pool = "ISO_Storage" # Specify your storage pool
unmount_iso = true
# VM System Settings
qemu_agent = true
# VM Hard Disk Settings
scsi_controller = "virtio-scsi-pci"
disks {
disk_size = "20G"
format = "raw"
storage_pool = "pool1" #Specify your storage pool
storage_pool_type = "zfs" #Specify pool type
type = "virtio"
}
# VM CPU Settings
cores = "8"
# VM Memory Settings
memory = "16384"
# VM Network Settings
network_adapters {
model = "virtio"
bridge = "vmbr0"
firewall = "false"
}
# VM Cloud-Init Settings
cloud_init = true
cloud_init_storage_pool = "pool1" # Specify your storage pool
# PACKER Boot Commands
boot_command = [
"<esc><wait>",
"e<wait>",
"<down><down><down><end>",
"<bs><bs><bs><bs><wait>",
"autoinstall ds=nocloud-net;s=/cidata/ ---<wait>",
"<f10><wait>"
]
cd_files = ["./http/meta-data", "./http/user-data"]
cd_label = "cidata"
boot = "c"
boot_wait = "5s"
# PACKER Autoinstall Settings
#http_directory = "http"
# (Optional) Bind IP Address and Port
#http_bind_address = "0.0.0.0"
#http_port_min = 8802
#http_port_max = 8802
ssh_username = "ubuntu"
# (Option 1) Add your Password here
ssh_password = "ubuntu"
# - or -
# (Option 2) Add your Private SSH KEY file here
#ssh_private_key_file = "~/.ssh/ansible"
# Raise the timeout, when installation takes longer
ssh_timeout = "20m"
}
# Build Definition to create the VM Template
build {
name = "Hashi-ubuntu-server-jammy"
sources = ["source.proxmox.ubuntu-server-jammy"]
# Provisioning the VM Template for Cloud-Init Integration in Proxmox #1
provisioner "shell" {
inline = [
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"sudo rm /etc/ssh/ssh_host_*",
"sudo truncate -s 0 /etc/machine-id",
"sudo apt -y autoremove --purge",
"sudo apt -y clean",
"sudo apt -y autoclean",
"sudo cloud-init clean",
"sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg",
"sudo sync"
]
}
provisioner "shell" {
inline = [
"sudo wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg",
"echo deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main | sudo tee /etc/apt/sources.list.d/hashicorp.list",
"sudo apt update",
"sudo apt install nomad -y",
"sudo apt install consul -y",
"sudo apt install vault -y",
]
}
# Provisioning the VM Template for Cloud-Init Integration in Proxmox #2
provisioner "file" {
source = "99-pve.cfg"
destination = "/tmp/99-pve.cfg"
}
# Provisioning the VM Template for Cloud-Init Integration in Proxmox #3
provisioner "shell" {
inline = ["sudo cp /tmp/99-pve.cfg /etc/cloud/cloud.cfg.d/99-pve.cfg"]
}
# Add additional provisioning scripts here
# ...
}