• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Packer
  • Install
  • Tutorials
  • Documentation
  • Guides
  • Plugins
  • Try Cloud(opens in new tab)
  • Sign up
Packer Home

Plugins

Skip to main content
  • Plugins

      • Overview
      • Clone
      • ISO

  • Resources

  • Tutorial Library
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Packer
  3. Plugins
  4. Builders
  5. Proxmox
  6. ISO
Community
v1.1.1

»Proxmox Builder (from an ISO)

Type: proxmox-iso Artifact BuilderId: proxmox.iso

The proxmox-iso Packer builder is able to create new images for use with Proxmox. The builder takes an ISO image, runs any provisioning necessary on the image after launching it, then creates a virtual machine template. This template can then be used as to create new virtual machines within Proxmox.

The builder does not manage templates. Once it creates a template, it is up to you to use it or delete it.

Configuration Reference

There are many configuration options available for the builder. They are segmented below into two categories: required and optional parameters. Within each category, the available configuration keys are alphabetized.

In addition to the options listed here, a communicator can be configured for this builder.

If no communicator is defined, an SSH key is generated for use, and is used in the image's Cloud-Init settings for provisioning.

Required:

  • proxmox_url (string) - URL to the Proxmox API, including the full path, so https://<server>:<port>/api2/json for example. Can also be set via the PROXMOX_URL environment variable.

  • username (string) - Username when authenticating to Proxmox, including the realm. For example user@pve to use the local Proxmox realm. When using token authentication, the username must include the token id after an exclamation mark. For example, user@pve!tokenid. Can also be set via the PROXMOX_USERNAME environment variable.

  • password (string) - Password for the user. For API tokens please use token. Can also be set via the PROXMOX_PASSWORD environment variable. Either password or token must be specifed. If both are set, token takes precedence.

  • token (string) - Token for authenticating API calls. This allows the API client to work with API tokens instead of user passwords. Can also be set via the PROXMOX_TOKEN environment variable. Either password or token must be specifed. If both are set, token takes precedence.

  • node (string) - Which node in the Proxmox cluster to start the virtual machine on during creation.

  • iso_file (string) - Path to the ISO file to boot from, expressed as a proxmox datastore path, for example local:iso/Fedora-Server-dvd-x86_64-29-1.2.iso. Either iso_file OR iso_url must be specifed.

  • iso_url (string) - URL to an ISO file to upload to Proxmox, and then boot from. Either iso_file OR iso_url must be specifed.

  • iso_storage_pool (string) - Proxmox storage pool onto which to upload the ISO file.

  • iso_checksum (string) - Checksum of the ISO file. Type of the checksum is infered based on string length, or can be explicitly prefixed with md5:, sha1:, sha256:, sha512: or set to none. Corruption of large files, such as ISOs, can occur during transfer from time to time. As such, setting this to none is not recommended.

Optional:

  • insecure_skip_tls_verify (bool) - Skip validating the certificate.

  • task_timeout (duration string | ex: "10m") - The timeout for Promox API operations, e.g. clones. Defaults to 1 minute.

  • pool (string) - Name of resource pool to create virtual machine in.

  • vm_name (string) - Name of the virtual machine during creation. If not given, a random uuid will be used.

  • vm_id (int) - The ID used to reference the virtual machine. This will also be the ID of the final template. If not given, the next free ID on the node will be used.

  • memory (int) - How much memory, in megabytes, to give the virtual machine. Defaults to 512.

  • cores (int) - How many CPU cores to give the virtual machine. Defaults to 1.

  • sockets (int) - How many CPU sockets to give the virtual machine. Defaults to 1

  • cpu_type (string) - The CPU type to emulate. See the Proxmox API documentation for the complete list of accepted values. For best performance, set this to host. Defaults to kvm64.

  • os (string) - The operating system. Can be wxp, w2k, w2k3, w2k8, wvista, win7, win8, win10, l24 (Linux 2.4), l26 (Linux 2.6+), solaris or other. Defaults to other.

  • vga (object) - The graphics adapter to use. Example:

    {
      "type": "vmware",
      "memory": 32
    }
    
    • type (string) - Can be cirrus, none, qxl,qxl2, qxl3, qxl4, serial0, serial1, serial2, serial3, std, virtio, vmware. Defaults to std.

    • memory (int) - How much memory to assign.

  • network_adapters (array of objects) - Network adapters attached to the virtual machine. Example:

    [
      {
        "model": "virtio",
        "bridge": "vmbr0",
        "vlan_tag": "10",
        "firewall": true
      }
    ]
    
    • bridge (string) - Required. Which Proxmox bridge to attach the adapter to.

    • model (string) - Model of the virtual network adapter. Can be rtl8139, ne2k_pci, e1000, pcnet, virtio, ne2k_isa, i82551, i82557b, i82559er, vmxnet3, e1000-82540em, e1000-82544gc or e1000-82545em. Defaults to e1000.

    • mac_address (string) - Give the adapter a specific MAC address. If not set, defaults to a random MAC. If value is "repeatable", value of MAC address is deterministic based on VM ID and NIC ID.

    • vlan_tag (string) - If the adapter should tag packets. Defaults to no tagging.

    • firewall (bool) - If the interface should be protected by the firewall. Defaults to false.

    • packet_queues (int) - Number of packet queues to be used on the device. Values greater than 1 indicate that the multiqueue feature is activated. For best performance, set this to the number of cores available to the virtual machine. CPU load on the host and guest systems will increase as the traffic increases, so activate this option only when the VM has to handle a great number of incoming connections, such as when the VM is operating as a router, reverse proxy or a busy HTTP server. Requires virtio network adapter. Defaults to 0.

  • serials ([]string) - A list (max 4 elements) of serial ports attached to the virtual machine. It may pass through a host serial device /dev/ttyS0 or create unix socket on the host socket. Each element can be socket or responding to pattern /dev/.+. Example:

    [
      "socket",
      "/dev/ttyS1"
    ]
    
  • disks (array of objects) - Disks attached to the virtual machine. Example:

    [
      {
        "type": "scsi",
        "disk_size": "5G",
        "storage_pool": "local-lvm",
        "storage_pool_type": "lvm"
      }
    ]
    
    • storage_pool (string) - Required. Name of the Proxmox storage pool to store the virtual machine disk on. A local-lvm pool is allocated by the installer, for example.

    • storage_pool_type (string) - Required. The type of the pool, can be lvm, lvm-thin, zfspool, cephfs, rbd or directory.

    • type (string) - The type of disk. Can be scsi, sata, virtio or ide. Defaults to scsi.

    • disk_size (string) - The size of the disk, including a unit suffix, such as 10G to indicate 10 gigabytes.

    • cache_mode (string) - How to cache operations to the disk. Can be none, writethrough, writeback, unsafe or directsync. Defaults to none.

    • format (string) - The format of the file backing the disk. Can be raw, cow, qcow, qed, qcow2, vmdk or cloop. Defaults to raw.

    • io_thread (bool) - Create one I/O thread per storage controller, rather than a single thread for all I/O. This can increase performance when multiple disks are used. Requires virtio-scsi-single controller and a scsi or virtio disk. Defaults to false.

  • template_name (string) - Name of the template. Defaults to the generated name used during creation.

  • template_description (string) - Description of the template, visible in the Proxmox interface.

  • unmount_iso (bool) - If true, remove the mounted ISO from the template after finishing. Defaults to false.

  • onboot (boolean) - Specifies whether a VM will be started during system bootup. Defaults to false.

  • qemu_agent (boolean) - Enables QEMU Agent option for this VM. When enabled, then qemu-guest-agent must be installed on the guest. When disabled, then ssh_host should be used. Defaults to true.

  • disable_kvm (boolean) - Disables KVM hardware virtualization. Defaults to false.

  • scsi_controller (string) - The SCSI controller model to emulate. Can be lsi, lsi53c810, virtio-scsi-pci, virtio-scsi-single, megasas, or pvscsi. Defaults to lsi.

  • cloud_init (bool) - If true, add an empty Cloud-Init CDROM drive after the virtual machine has been converted to a template. Defaults to false.

  • cloud_init_storage_pool (string) - Name of the Proxmox storage pool to store the Cloud-Init CDROM on. If not given, the storage pool of the boot device will be used.

  • additional_iso_files (array of objects) - Additional ISO files attached to the virtual machine. Example:

    [
      {
        "device": "scsi5",
        "iso_file": "local:iso/virtio-win-0.1.185.iso",
        "unmount": true,
        "iso_checksum": "af2b3cc9fa7905dea5e58d31508d75bba717c2b0d5553962658a47aebc9cc386"
      }
    ]
    
    • device (string) - Bus type and bus index that the ISO will be mounted on. Can be ideX, sataX or scsiX. For ide the bus index ranges from 0 to 3, for sata form 0 to 5 and for scsi from 0 to 30. Defaults to ide3 since ide2 is generally the boot drive.

    • iso_file (string) - Path to the ISO file to boot from, expressed as a proxmox datastore path, for example local:iso/Fedora-Server-dvd-x86_64-29-1.2.iso. Either iso_file OR iso_url OR cd_files must be specifed.

    • iso_url (string) - URL to an ISO file to upload to Proxmox, and then boot from. Either iso_file OR iso_url OR cd_files must be specifed.

    • iso_storage_pool (string) - Proxmox storage pool onto which to upload the ISO file.

    • iso_checksum (string) - Checksum of the ISO file.

    • unmount (bool) - If true, remove the mounted ISO from the template after finishing. Defaults to false.

    Optional

    • cd_files ([]string) - A list of files to place onto a CD that is attached when the VM is booted. This can include either files or directories; any directories will be copied onto the CD recursively, preserving directory structure hierarchy. Symlinks will have the link's target copied into the directory tree on the CD where the symlink was. File globbing is allowed. Overrides any of iso_file or iso_url set. Requires iso_storage_pool to be set

      Usage example (JSON):

      "cd_files": ["./somedirectory/meta-data", "./somedirectory/user-data"],
      "cd_label": "cidata",
      

      Usage example (HCL):

      cd_files = ["./somedirectory/meta-data", "./somedirectory/user-data"]
      cd_label = "cidata"
      

      The above will create a CD with two files, user-data and meta-data in the CD root. This specific example is how you would create a CD that can be used for an Ubuntu 20.04 autoinstall.

      Since globbing is also supported,

      cd_files = ["./somedirectory/*"]
      cd_label = "cidata"
      

      Would also be an acceptable way to define the above cd. The difference between providing the directory with or without the glob is whether the directory itself or its contents will be at the CD root.

      Use of this option assumes that you have a command line tool installed that can handle the iso creation. Packer will use one of the following tools:

      • xorriso
      • mkisofs
      • hdiutil (normally found in macOS)
      • oscdimg (normally found in Windows as part of the Windows ADK)
- `cd_content` (map[string]string) - Key/Values to add to the CD. The keys represent the paths, and the values
  contents. It can be used alongside `cd_files`, which is useful to add large
  files without loading them into memory. If any paths are specified by both,
  the contents in `cd_content` will take precedence.

  Usage example (HCL):

  ```hcl
  cd_files = ["vendor-data"]
  cd_content = {
    "meta-data" = jsonencode(local.instance_data)
    "user-data" = templatefile("user-data", { packages = ["nginx"] })
  }
  cd_label = "cidata"
  ```

- `cd_label` (string) - CD Label
  • http_interface - (string) - Name of the network interface that Packer gets HTTPIP from. Defaults to the first non loopback interface.

  • vm_interface - (string) - Name of the network interface that Packer gets the VMs IP from. Defaults to the first non loopback interface.

  • boot - (string) - Override default boot order. Format example order=virtio0;ide2;net0. Prior to Proxmox 6.2-15 the format was cdn (c:CDROM -> d:Disk -> n:Network)

  • bios - (string) - Set the machine bios. This can be set to ovmf or seabios. The default value is seabios.

  • efi_config - (object) - Set the efidisk storage options. This needs to be set if you use ovmf uefi boot (supersedes the efidisk option).

    Usage example (JSON):

    {
      "efi_storage_pool": "local",
      "pre_enrolled_keys": true,
      "efi_type": "4m"
    }
    
    • storage_pool - (string) - Name of the Proxmox storage pool to store the EFI disk on.

    • efitype - (string) - Specifies the version of the OVMF firmware to be used. Can be 2m or 4m. Defaults to 4m.

    • pre_enrolled_keys - (boolean) - Whether Microsoft Standard Secure Boot keys should be pre-loaded on the EFI disk. Defaults to false.

  • efidisk - (string) - This option is deprecated, please use efi_config instead.

  • machine - (string) - Set themachine type. i440fx or q35.

Boot Command

The boot configuration is very important: boot_command specifies the keys to type when the virtual machine is first booted in order to start the OS installer. This command is typed after boot_wait, which gives the virtual machine some time to actually load.

The boot_command is an array of strings. The strings are all typed in sequence. It is an array only to improve readability within the template.

There are a set of special keys available. If these are in your boot command, they will be replaced by the proper key:

  • <bs> - Backspace

  • <del> - Delete

  • <enter> <return> - Simulates an actual "enter" or "return" keypress.

  • <esc> - Simulates pressing the escape key.

  • <tab> - Simulates pressing the tab key.

  • <f1> - <f12> - Simulates pressing a function key.

  • <up> <down> <left> <right> - Simulates pressing an arrow key.

  • <spacebar> - Simulates pressing the spacebar.

  • <insert> - Simulates pressing the insert key.

  • <home> <end> - Simulates pressing the home and end keys.

  • <pageUp> <pageDown> - Simulates pressing the page up and page down keys.

  • <menu> - Simulates pressing the Menu key.

  • <leftAlt> <rightAlt> - Simulates pressing the alt key.

  • <leftCtrl> <rightCtrl> - Simulates pressing the ctrl key.

  • <leftShift> <rightShift> - Simulates pressing the shift key.

  • <leftSuper> <rightSuper> - Simulates pressing the ⌘ or Windows key.

  • <wait> <wait5> <wait10> - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more.

  • <waitXX> - Add an arbitrary pause before sending any additional keys. The format of XX is a sequence of positive decimal numbers, each with optional fraction and a unit suffix, such as 300ms, 1.5h or 2h45m. Valid time units are ns, us (or µs), ms, s, m, h. For example <wait10m> or <wait1m20s>.

  • <XXXOn> <XXXOff> - Any printable keyboard character, and of these "special" expressions, with the exception of the <wait> types, can also be toggled on or off. For example, to simulate ctrl+c, use <leftCtrlOn>c<leftCtrlOff>. Be sure to release them, otherwise they will be held down until the machine reboots. To hold the c key down, you would use <cOn>. Likewise, <cOff> to release.

  • {{ .HTTPIP }} {{ .HTTPPort }} - The IP and port, respectively of an HTTP server that is started serving the directory specified by the http_directory configuration parameter. If http_directory isn't specified, these will be blank!

  • {{ .Name }} - The name of the VM.

Example boot command. This is actually a working boot command used to start an CentOS 6.4 installer:

In JSON:

"boot_command": [
    "<tab><wait>",
    " ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg<enter>"
 ]

In HCL2:

boot_command = [
    "<tab><wait>",
    " ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg<enter>"
 ]

The example shown below is a working boot command used to start an Ubuntu 12.04 installer:

In JSON:

"boot_command": [
  "<esc><esc><enter><wait>",
  "/install/vmlinuz noapic ",
  "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
  "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
  "hostname={{ .Name }} ",
  "fb=false debconf/frontend=noninteractive ",
  "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
  "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
  "initrd=/install/initrd.gz -- <enter>"
]

In HCL2:

boot_command = [
  "<esc><esc><enter><wait>",
  "/install/vmlinuz noapic ",
  "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
  "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
  "hostname={{ .Name }} ",
  "fb=false debconf/frontend=noninteractive ",
  "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
  "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
  "initrd=/install/initrd.gz -- <enter>"
]

For more examples of various boot commands, see the sample projects from our community templates page.

Optional:

  • boot_keygroup_interval (duration string | ex: "1h5m2s") - Time to wait after sending a group of key pressses. The value of this should be a duration. Examples are 5s and 1m30s which will cause Packer to wait five seconds and one minute 30 seconds, respectively. If this isn't specified, a sensible default value is picked depending on the builder type.

  • boot_wait (duration string | ex: "1h5m2s") - The time to wait after booting the initial virtual machine before typing the boot_command. The value of this should be a duration. Examples are 5s and 1m30s which will cause Packer to wait five seconds and one minute 30 seconds, respectively. If this isn't specified, the default is 10s or 10 seconds. To set boot_wait to 0s, use a negative number, such as "-1s"

  • boot_command ([]string) - This is an array of commands to type when the virtual machine is first booted. The goal of these commands should be to type just enough to initialize the operating system installer. Special keys can be typed as well, and are covered in the section below on the boot command. If this is not specified, it is assumed the installer will start itself.

Http directory configuration

Packer will create an http server serving http_directory when it is set, a random free port will be selected and the architecture of the directory referenced will be available in your builder.

Example usage from a builder:

wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg

Optional:

  • http_directory (string) - Path to a directory to serve using an HTTP server. The files in this directory will be available over HTTP that will be requestable from the virtual machine. This is useful for hosting kickstart files and so on. By default this is an empty string, which means no HTTP server will be started. The address and port of the HTTP server will be available as variables in boot_command. This is covered in more detail below.

  • http_content (map[string]string) - Key/Values to serve using an HTTP server. http_content works like and conflicts with http_directory. The keys represent the paths and the values contents, the keys must start with a slash, ex: /path/to/file. http_content is useful for hosting kickstart files and so on. By default this is empty, which means no HTTP server will be started. The address and port of the HTTP server will be available as variables in boot_command. This is covered in more detail below. Example:

      http_content = {
        "/a/b"     = file("http/b")
        "/foo/bar" = templatefile("${path.root}/preseed.cfg", { packages = ["nginx"] })
      }
    
  • http_port_min (int) - These are the minimum and maximum port to use for the HTTP server started to serve the http_directory. Because Packer often runs in parallel, Packer will choose a randomly available port in this range to run the HTTP server. If you want to force the HTTP server to be on one port, make this minimum and maximum port the same. By default the values are 8000 and 9000, respectively.

  • http_port_max (int) - HTTP Port Max

  • http_bind_address (string) - This is the bind address for the HTTP server. Defaults to 0.0.0.0 so that it will work with any network interface.

Example: Fedora with kickstart

Here is a basic example creating a Fedora 29 server image with a Kickstart file served with Packer's HTTP server. Note that the iso file needs to be manually downloaded.

{
  "variables": {
    "username": "apiuser@pve",
    "password": "supersecret"
  },
  "builders": [
    {
      "type": "proxmox",
      "proxmox_url": "https://my-proxmox.my-domain:8006/api2/json",
      "insecure_skip_tls_verify": true,
      "username": "{{user `username`}}",
      "password": "{{user `password`}}",

      "node": "my-proxmox",
      "network_adapters": [
        {
          "bridge": "vmbr0"
        }
      ],
      "disks": [
        {
          "type": "scsi",
          "disk_size": "5G",
          "storage_pool": "local-lvm",
          "storage_pool_type": "lvm"
        }
      ],

      "iso_file": "local:iso/Fedora-Server-dvd-x86_64-29-1.2.iso",
      "http_directory": "config",
      "boot_wait": "10s",
      "boot_command": [
        "<up><tab> ip=dhcp inst.cmdline inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg<enter>"
      ],

      "ssh_username": "root",
      "ssh_timeout": "15m",
      "ssh_password": "packer",

      "unmount_iso": true,
      "template_name": "fedora-29",
      "template_description": "Fedora 29-1.2, generated on {{ isotime \"2006-01-02T15:04:05Z\" }}"
    }
  ]
}
Edit this page on GitHub

On this page

  1. Proxmox Builder (from an ISO)
  2. Configuration Reference
  3. Boot Command
  4. Http directory configuration
  5. Example: Fedora with kickstart
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)