pitchblack408
pitchblack408

Reputation: 2983

How to use HashiCorp Packer with the VMWare plugin and vmware-iso Builder to Create an VMWare ISO?

I just recently started using HashiCorp Packer and I am interested in creating some VMs, specifically ones that are made for VMWare. I did some searching and found that there are two VMWare plugins, which are VMware and vSphere. The VMware plugin has a builder named vmware-iso, which create an iso locally and the vSphere plugin has a builder named vsphere-iso, which builds a virtual machine image on a vSphere cluster or an ESXi. I am currently interested in getting the vmware-iso to work.

When I run the packer build command, I am getting the error:

vmware-iso.ubuntu: error starting virtual machine: VMware error: Warning: program compiled against libxml 212 using older 209

How do I get the vmware-iso builder to work?

I have installed packer v1.11.2, the VMWare plugin v1.1.0, and the free version of VMware Workstation Pro 17.6.1 build-24319023 on my Rocky Linux 9.5 machine.

ubuntu.pkr.hcl

packer {
  required_plugins {
    vmware = {
      version = "~> 1"
      source = "github.com/hashicorp/vmware"
    }
  }
}
source "vmware-iso" "ubuntu" {
  iso_url            = format(
    "https://releases.ubuntu.com/%s.%s/ubuntu-%s-live-server-amd64.iso",
    split(".", var.ubuntu_release_version)[0],
    split(".", var.ubuntu_release_version)[1],
    var.ubuntu_release_version
  )
  iso_checksum       = var.ubuntu_iso_checksum
  ssh_username       = "packer"
  ssh_password       = "packer"
  shutdown_command   = "echo 'packer' | sudo -S shutdown -P now"
  vm_name            = "ubuntu-vm"
  disk_size          = 10000
  memory             = 1024
  cpus               = 1
  communicator       = "ssh"
}

build {
  sources = ["source.vmware-iso.ubuntu",
  ]

  provisioner "shell" {
    environment_vars = [
      "FOO=hello world",
    ]
    inline = [
      "echo Adding file to Docker Container",
      "echo \"FOO is $FOO\" > example.txt",
    ]
  }

  provisioner "shell" {
    inline = ["echo This provisioner runs last"]
  }
}

variable "ubuntu_release_version" {
  type    = string
  default = "22.04.5"
}
variable "ubuntu_release_name" {
  type    = string
  default = "jammy"
}
variable "ubuntu_iso_checksum" {
  type = string
  default = "sha256:9bc6028870aef3f74f4e16b900008179e78b130e6b0b9a140635434a46aa98b0"
}

vmware-iso.ubuntu: error starting virtual machine: VMware error: Warning: program compiled against libxml 212 using older 209

Upvotes: 0

Views: 291

Answers (0)

Related Questions