DEV Community

Discussion on: Creating proxmox templates with packer

Collapse
lethargosapatheia profile image
lethargosapatheia • Edited on

I was able to solve it, actually, up to the point where you have a readily available template with cloud-init ready to read the user-data. Just to give you a head start :)

       "boot_command": [
        "<esc><enter><f6><esc><wait> ",
        "<bs><bs><bs><bs><bs>",
        "ip={{ user `vm_ip` }}::{{ user `vm_gateway` }}:{{ user `vm_netmask` }}::::{{ user `vm_dns` }} ",
        "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ",
        "--- <enter>"
      ]
Enter fullscreen mode Exit fullscreen mode

This configures autoinstall, which can run cloud-init commands. And will run cloud-init anyway.
These are the variables:

  "variables": {
    "vm_ip": "10.0.0.159",
    "vm_netmask": "255.255.255.0",
    "vm_gateway": "10.0.0.126",
    "vm_dns": "10.0.0.126",
    "search_domain:": "domain.internal",
    "dns_server:": "1.1.1.1",
    "template_name": "ubuntu-20-04.domain.internal",
    "template_description": "Ubuntu 20.04, generated by packer on {{ isotime }}",
    "playbook": "setup/work.yml",
Enter fullscreen mode Exit fullscreen mode

Then you can reset cloud-init through ansible (run by packer), for example.

If you want to write an updated article, I'll be happy to help, if you think you need any, of course!