Packer ESXi build templates

4,344 views
Skip to first unread message

Don Ky

unread,
Jan 4, 2014, 10:13:49 PM1/4/14
to packe...@googlegroups.com
All, 

Does anyone have a working template for the ESXi uploader build?  I'm having a terrible time getting this to work.  I've tried to customize:


To get a centos6 build going but failed.  Packer complains that vnc is not available but I logged into the esx service console and it appears that the VM never even makes it past the startup phase.  I've tested it working with the ttylinux build though.  Here is the template I'm working on:

{
  "provisioners": [{
    "type": "shell",
      "scripts": [
          "scripts/install.sh"
       ]
  }],
  "variables": {
    "remote_host": ""
  },
  "builders": [
    {
      "type": "vmware-iso",
      "remote_type": "esx5",
      "remote_host": "{{user `remote_host`}}",
      "remote_username": "root",
      "remote_password": "",
      "vmdk_name": "ttylinux",
      "boot_command": [
        "<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6.ks.cfg<enter><wait>"
      ],
      "vnc_port_min": 8080,
      "vnc_port_max": 8080,
      "boot_wait": "30s",
      "disk_size": 15,
      "disk_type_id": "sesparse",
      "guest_os_type": "other26xlinux",
      "iso_checksum": "0d9dc37b5dd4befa1c440d2174e88a87",
      "iso_checksum_type": "md5",
      "iso_urls": [
      ],
      "ssh_skip_request_pty": true,
      "ssh_username": "root",
      "ssh_password": "password",
      "ssh_port": 22,
      "ssh_wait_timeout": "60s",
      "shutdown_command": "/sbin/shutdown -h",
      "vmx_data": {
        "ethernet0.networkName": "VM Network",
    "memsize": "1024",
        "numvcpus": "1",
        "cpuid.coresPerSocket": "1",
        "ide0:0.fileName": "ttylinux.vmdk",
        "ide0:0.present": "TRUE",
        "ide0:0.redo": "",
        "scsi0:0.present": "FALSE"
      }
    }
  ]
}

Any pointers would be helpful.

Thanks

sbal...@tidemark.com

unread,
Jan 28, 2014, 9:20:34 AM1/28/14
to packe...@googlegroups.com
Hey 

I have been trying to use ESXi builder but i am stuck at Determining the host IP. Did you get working by any chance ?

Regards,
Sandeep

Don Ky

unread,
Feb 10, 2014, 9:55:26 AM2/10/14
to packe...@googlegroups.com
Hi, I never got this working. Gave up on it since the builder is a bit odd and I had no time to sit there debugging it.  I think a better approach to this plugin would have been similar to the vsphere provider where you build locally and then push up to esxi via post-processor.  

Nelson Jeppesen

unread,
Feb 12, 2014, 8:10:37 PM2/12/14
to packe...@googlegroups.com
I asked for help on another thread, but no one replied. Are all of you having issues with packer not creating the VMX file too? I can't it working with esxi 5.0; It says it creates teh vmx file but it never shows up on the esxi host.

Thomas Guthmann

unread,
Feb 18, 2014, 3:59:38 AM2/18/14
to packe...@googlegroups.com
Hey guys,

Run packer in debug mode and if you cannot see anything obvious paste
the output in an email with your template.

$ export PACKER_LOG=1
$ packer build foobar

Ref: http://www.packer.io/docs/other/debugging.html

Thomas

Rafael Nunes

unread,
Mar 12, 2014, 8:18:39 PM3/12/14
to packe...@googlegroups.com
Hi Sandeep, just update to packer 0.5.2 and this error should be gone.

I was getting the same error as you, then I found out that this pull request:

solved the issue.

Now my issue on creating a VM on ESXi 5.5 is with network. Apparently the vanilla VMX template used by packer isn't setting up the network as ESXi 5.5 is expecting. But I'll not hijack the thread to talk about this :P

Cheers

Pierre Klovsjö

unread,
Mar 13, 2014, 3:13:04 AM3/13/14
to packe...@googlegroups.com
Hi Rafael,

What your issue with the network part?

Rgds,
Pierre

Rafael Nunes

unread,
Mar 13, 2014, 12:32:55 PM3/13/14
to packe...@googlegroups.com
On the same ESXi 5.5 host:
  • if I create a VM manually through vCenter webclient wizard, using the same hardware version as packer does (v9), its network interface works normally, but...
  • if I create a VM via packer, this VM doesn't have its network interface working. The machine doesn't get an IP address from my DHCP server.
But I had to stop before dig deeper into the issue. Stopped just after realize some different options regarding "ethernet.*" on the VMX file created by packer and the one created by vCenter webclient wizard.

Once I troubleshoot a bit more I can share finer details, but if you have any tips I'd appreciate.

Tks

Pierre Klovsjö

unread,
Mar 14, 2014, 3:14:37 AM3/14/14
to packe...@googlegroups.com
Hi,

It's not due to the fact that when you create/duplicate a RH/COS 6.X machine the eth0 becomes eth1 hence the issues getting a functioning network interface?
We are having the same 'functionality' in our Production systems using Templates as defined my VMware. Our post scripts always redo the NIC's.

As a check:
If you check in /etc/udev/rules.d/70-persistent-net.rules after you created the VM with Packer you'll see that you have the eth0 (from the source VM) and then eth1 which corresponds to your NIC (check MAC). Delete eth0 line completely then on the second line change eth1 => eth0, reboot!


Anyways, in my postconfig i run this:

"execute_command": "echo 'TheDude' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"scripts": [
     "scripts/yum.sh",
     "scripts/sysctl.sh",
     "scripts/vmtools.sh",
     "scripts/network.sh",
     "scripts/eth1toeth0.sh"
],
"type": "shell"
}


eth1toeth0.sh Script:

#!/bin/bash -eux

# Remove 70-persistent-net.rules and create eth0 during next boot!
cp /etc/udev/rules.d/70-persistent-net.rules /var/tmp/70-persistent-net.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules


Rgds,
Pierre

Alvaro Miranda Aguilera

unread,
Mar 14, 2014, 8:21:54 PM3/14/14
to packe...@googlegroups.com
you also need to remove the HW MAC address from the configuration file

      "cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ori",
      "sed -i -e '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config",
      "for nic in /etc/sysconfig/network-scripts/ifcfg-eth*; do sed -i /HWADDR/d $nic; done",
      "rm /etc/udev/rules.d/70-persistent-net.rules"

here i also set UseDNS no in sshd config to speed up the ssh into the guest.

Alvaro


--
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rafael Nunes

unread,
Mar 18, 2014, 9:39:23 PM3/18/14
to packe...@googlegroups.com
But Pierre, Alvaro,
I'm not using the vSphere post-processor, instead, I'm using the vmware-iso builder to create a VM directly on the ESXi host.

Would these suggestion still apply?

Alvaro Miranda Aguilera

unread,
Mar 19, 2014, 12:12:26 AM3/19/14
to packe...@googlegroups.com
those are commands to be run in the linux guest, so yes.

give it a try.

Alvaro.

Rafael Nunes

unread,
Mar 19, 2014, 11:21:16 PM3/19/14
to packe...@googlegroups.com
But I'm just installing the guest.
The point where I am on is during the OS installation, right after packer typed in the command to have (in this case), the CentOS installation booting and trying to get the kickstart file (used for the unattended install) from the small webserver created by packer to serve the file.

screen below comes from tty2 (after a <alt+f2>)

On the attached vmware.log file (from this VM on the screenshots) I found the following messages:

vcpu-0| I120: [msg.mac.cantGetNetworkName] Unable to get networkName or devName for ethernet0
vcpu-0| I120: [msg.device.startdisconnected] Virtual device Ethernet0 will start disconnected

Googling for it, I found these KB articles:
KB2065812 and KB2062300 from last week, March 11.

Although the PR 1119268 doesn't exactly describe my scenario, I'll install the ESXi 5.5 Update 1 and give it a try.

Gime a heads up if I am sharing too much.

Cheers

vmware.log

Alvaro Miranda Aguilera

unread,
Mar 20, 2014, 4:40:06 AM3/20/14
to packe...@googlegroups.com

On Thu, Mar 20, 2014 at 4:21 PM, Rafael Nunes <dath...@gmail.com> wrote:
KB2062300

can you set a different nic type?


the commands I gave you are needed in the guest to avoid issues when the mac/address change when you start deploying this guest. :)



zdman

unread,
Jun 6, 2014, 3:44:44 PM6/6/14
to packe...@googlegroups.com
I am running into the same issue. Did patching or updating your esxi fix the issue?
Or did you just set a mac address in the vmx-data?

Thanks

zdman

unread,
Jun 9, 2014, 2:56:12 PM6/9/14
to packe...@googlegroups.com
So I solved my own problem, and figured I'd come back to the board and share. Since it's a pet peeve of mine when people solve a problem they have, and don't come back to the board and post their solution...

The problem I had was a networking issue the same one that was found by Rafael Nunes and I quoted him below. It was a networking issue, for some reason esxi wouldn't initialize the networking interface.

I did the following:

1) Installed all the patches for ESXi 5.1. (This was to fix some networking bug that was discussed in the quoted text.)
2) had the following configurations in my .json file:

    {
      "name": "baseimage~esxi",
      "vm_name": "baseimage~esxi",

      "remote_type": "esx5",
      "remote_host": "10.50.10.110",
      "remote_datastore": "datastore1",
      "remote_username": "root",
      "remote_password": "password",

      "type": "vmware-iso",
      "guest_os_type": "linux",
      "tools_upload_flavor": "linux",
      "boot_wait": "10s",
      "headless": false,
      "boot_command": [
        "<tab> text inst.sshd ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/sl-ks.cfg<enter><wait>"
      ],
      "vmx_data": {
        "memsize": "1024",
        "numvcpus": "2",

        "ethernet0.present": "TRUE",
        "ethernet0.startConnected": "TRUE",
        "ethernet0.virtualDev": "e1000",
        "ethernet0.networkName": "VM Network",
        "ethernet0.addressType": "generated",
        "ethernet0.generatedAddressOffset": "0",
        "ethernet0.wakeOnPcktRcv": "FALSE"
      },
      "disk_size": "{{user `disk_size`}}",
      "http_directory": "{{user `http_directory`}}",
      "iso_url": "{{user `iso_url`}}",
      "iso_checksum": "{{user `iso_checksum`}}",
      "iso_checksum_type": "{{user `iso_checksum_type`}}",
      "shutdown_command": "{{user `shutdown_command`}}",
      "ssh_username": "{{user `ssh_username`}}",
      "ssh_password": "{{user `ssh_password`}}",
      "ssh_wait_timeout": "{{user `ssh_wait_timeout`}}"
    },

Hope this helped someone else.
Thanks.

Sheshagiri Rao Mallipedhi

unread,
Sep 30, 2014, 7:39:25 PM9/30/14
to packe...@googlegroups.com
Hi All,

I'm facing the same issue. When the vm starts booting it loads the anakonda-ks.cfg and says "sending request for ip information for eth0" for couple of minutes and then it falls back to the manual ip configuration screen(image attached).

-Sheshagiri
ip-configuration-screen.jpg

Ethan S.

unread,
Jan 7, 2015, 7:59:39 PM1/7/15
to packe...@googlegroups.com
As zdman mentioned, it is important to use the e1000 NIC type until VMware tools is installed, as the vmnet3 interface isn't supported in the kernel unless you are running open-vm-tools, and even then it can be hit or miss. If you are still having trouble, try running in debug mode as suggested above and pastebin your output.

Brandon Heller

unread,
Apr 12, 2015, 12:06:45 AM4/12/15
to packe...@googlegroups.com
The fix of adding the network interface details to vmx_data worked for me, as the VM was able to DHCP!  Many thanks to Ethan and zdman.

My setup: ESXi 5.5, using Packer 0.7.5.
Reply all
Reply to author
Forward
0 new messages