Packer -> vSphere -> Anyone ?

3,173 views
Skip to first unread message

Pierre Klovsjö

unread,
Feb 25, 2014, 2:26:45 PM2/25/14
to packe...@googlegroups.com
Greeting all,

Has anyone been successful using 'post-processors' and directly import the VM directly after build into vCenter?

Apart from having successful builds with, Stand Alone VM running in Fusion and vSphere on NFS/Local Datastore then manual Import to vCenter.

Things seem to run smoothly during build then, bam, error:
Build 'vmware-iso' errored: 1 error(s) occurred:
* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx


This is my Post-Processors,

"post-processors": [
        {
          "type": "vsphere",
          "vm_name": "{{user `fqdn`}}",
          "vm_folder": "ImportedVMs",
          "host": "192.168.198.50",
          "username": "TheDude",
          "password": "MySecretPasswd",
          "datacenter": "MyDC",
          "cluster": "Labo",
          "datastore": "{{user `datastore`}}",
          "vm_network": "VM Network",
          "resource_pool": "lab",
          "path_to_resource_pool": "host/Labo/Resources/lab",
          "insecure" : "true"
        }


I'm running a Mac with VMware Fusion 6.0.2 Prof with: vCenter Server Appliance 5.5, Openfiler (NFS) and 2 nested ESXi 5.1

Rgds,
Pierre

Alvaro Miranda Aguilera

unread,
Feb 25, 2014, 2:44:48 PM2/25/14
to packe...@googlegroups.com

On Wed, Feb 26, 2014 at 8:26 AM, Pierre Klovsjö <klo...@gmail.com> wrote:
mitchellh.vmware-esx


Where this name is coming from?  mitchellh.vmware-esx

Pierre Klovsjö

unread,
Feb 25, 2014, 3:06:22 PM2/25/14
to packe...@googlegroups.com
That's the output i get when running :

RockSolid:Build TheDude$ PACKER_LOG=DEBUG packer build 5_dev.json

2014/02/25 20:04:41 /Users/TheDude/packer/packer-builder-vmware-iso: 2014/02/25 20:04:41 remote command exited with '0': rm -rf /vmfs/volumes/datastore01/rhdev100

Build 'vmware-iso' errored: 1 error(s) occurred:

* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx
2014/02/25 20:04:41 ui error: Build 'vmware-iso' errored: 1 error(s) occurred:


* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx
2014/02/25 20:04:41 /Users/TheDude/packer/packer-command-build: 2014/02/25 20:04:41 Builds completed. Waiting on interrupt barrier...

Don Ky

unread,
Feb 25, 2014, 3:56:43 PM2/25/14
to packe...@googlegroups.com
Follow this thread:

I have it working:


Note there is a bug in the post-processor at least from 0.5.1 that couldn't find the path to the datastore upload you have to use "/".

Pierre Klovsjö

unread,
Feb 26, 2014, 3:39:35 AM2/26/14
to packe...@googlegroups.com
Thanks for the info but i don't seem to get it right. I am fairly new to packer and doc's seem to be a little weak...

Downloaded 0.5.2 yesterday and no change what so ever. Still trying different scenarios...

Could you provide an example that is working?

"post-processors": [
{
  "type": "vsphere",
  "vm_name": "rhdev100", <= A slash / here ?

  "vm_folder": "ImportedVMs",
  "host": "192.168.198.50",
  "username": "TheDude",
  "password": "MySecretPasswd",
  "datacenter": "MyDC",
  "cluster": "Labo",
  "datastore": "NFS_DATASTORE_02", <= A slash / here ?

  "vm_network": "VM Network",
  "resource_pool": "lab",
  "path_to_resource_pool": "host/Labo/Resources/lab",
  "insecure" : "true"
}


Pierre
Message has been deleted

Don Ky

unread,
Feb 26, 2014, 9:57:26 AM2/26/14
to packe...@googlegroups.com
Here is my "working" post-processor for vsphere.  The "/" was for the vm_folder value, I couldn't get the processor to upload to a folder on the datastore and it kept borking on me. I believe this was something with the ovftool though not a limitation of packer, it just calls the tool to do upload. 


"post-processors": [
 32     {
 33       "type": "vsphere",
 34       "host": "vs.example.com",
 35       "username": "vsp...@vsphere.local",
 36       "password": "abc123",
 37       "datacenter": "my-ds",
 38       "cluster": "openstack",
 39       "resource_pool": " ",
 40       "datastore": "ds1",
 41       "vm_folder": "/",
 42       "vm_name": "packer-rhel6-64",
 43       "vm_network": "Production",
 44       "insecure": "true"
 45     }
 46   ],

Pierre Klovsjö

unread,
Feb 26, 2014, 2:21:51 PM2/26/14
to packe...@googlegroups.com
Thanks a bunch!

But, once again no luck what so ever :-/

I started out with a local build, then an upload to vCenter with manual import and finally i wanted automation 100% and that's where i stand today.

So here comes my JSON file. Its something that has been copied and pasted from various sources. I haven't found a good source on how to construct the JSON file.


Usernames, Password and some other private stuff has been changed. I am running the 0.5.2 version downloaded yesterday on a Macbook Pro 15" Retina with Fusion 6.0.2

{
    "builders": [{ 
        "type": "vmware-iso",
        "iso_url": "http://192.168.198.1:8000/Build/ISO/CentOS-6.5-x86_64-bin-DVD1.iso",
        "output_directory": "rhdev100",
        "iso_checksum": "32c7695b97f7dcd1f59a77a71f64f2957dddf738",
        "iso_checksum_type": "sha1",
        "disk_size": "4096",
        "disk_type_id": "thin",
        "remote_host": "192.168.198.51",
        "remote_datastore": "NFS_DATASTORE_01",
        "remote_username": "root",
        "remote_password": "root",
        "remote_type": "esx5",
        "ssh_username": "root",
        "ssh_password": "root",
        "ssh_port": 22,
        "ssh_wait_timeout": "720s",
        "shutdown_command": "shutdown -h now",
        "boot_command": [
            "<tab>",
            "vmlinuz initrd=initrd.img ",
            "ks=http://192.168.198.1:8000/Build/kickstart/rh.cfg <enter><wait>"
        ],
      "boot_wait": "20s",
      "vm_name": "rhdev100",
      "vmx_data": {
        "virtualHW.version": "9",
        "ethernet0.networkName": "VM Network",
        "ethernet0.present": "TRUE",
        "ethernet0.virtualDev": "vmxnet3",
        "memsize": "512",
        "numvcpus": "1",
        "cpuid.coresPerSocket": "1",
        "scsi0:0.fileName": "disk.vmdk",
        "scsi0:0.present": "TRUE",
        "scsi0:0.redo": "",
        "ide0:0.present": "FALSE"
          }
    }],
      "post-processors": [{
        "type": "vsphere",
        "host": "192.168.198.50",
        "username": "admin",
        "password": "admin",

        "datacenter": "MyDC",
        "cluster": "Labo",
        "resource_pool": " ",
        "datastore": "NFS_DATASTORE_01",
        "vm_folder": "/",
        "vm_name": "rhdev100",
        "vm_network": "VM Network",
        "insecure" : "true"
       }]
}



And the output from the build process:

2014/02/26 19:14:03 /Users/TheDude/packer/packer-builder-vmware-iso: 2014/02/26 19:14:03 [DEBUG] Background SSH connection checker is testing
2014/02/26 19:14:03 /Users/TheDude/packer/packer-builder-vmware-iso: 2014/02/26 19:14:03 remote command exited with '0': rm -rf /vmfs/volumes/NFS_DATASTORE_01/rhdev100

Build 'vmware-iso' errored: 1 error(s) occurred:

* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx
2014/02/26 19:14:03 ui error: Build 'vmware-iso' errored: 1 error(s) occurred:


* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx
2014/02/26 19:14:03 /Users/TheDude/packer/packer-command-build: 2014/02/26 19:14:03 Builds completed. Waiting on interrupt barrier...
2014/02/26 19:14:03 machine readable: error-count []string{"1"}

==> Some builds didn't complete successfully and had errors:
2014/02/26 19:14:03 ui error:
==> Some builds didn't complete successfully and had errors:
2014/02/26 19:14:03 machine readable: vmware-iso,error []string{"1 error(s) occurred:\n\n* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx"}
--> vmware-iso: 1 error(s) occurred:


* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx
2014/02/26 19:14:03 ui error: --> vmware-iso: 1 error(s) occurred:


* Post-processor failed: Unknown artifact type, can't build box: mitchellh.vmware-esx

Don Ky

unread,
Feb 26, 2014, 2:59:28 PM2/26/14
to packe...@googlegroups.com
Can I ask what is all that extra stuff in your builders?  I think you've got something funny with that.  Here is an example of my builders for a standard kickstart install.  

 "builders": [
    {
      "boot_command": [
        "<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rhel6.ks.cfg<enter><wait>"
      ],
      "boot_wait": "5s",
      "disk_size": 10480,
      "guest_os_type": "rhel6-64",
      "headless": false,
      "http_directory": "http",
      "iso_checksum": "8e412886d663959f31c760d883bcd7b9",
      "iso_checksum_type": "md5",
      "iso_url": "file:/iso/rhel-server-6.5-i386-boot.iso",
      "name": "rhel6-64",
      "shutdown_command": "shutdown -h now",
      "skip_compaction": false,
      "ssh_password": "test",
      "ssh_port": 22,
      "ssh_username": "root",
      "ssh_wait_timeout": "10000s",
      "tools_upload_flavor": "linux",
      "type": "vmware-iso",
      "vmx_data": {
        "cpuid.coresPerSocket": "1",
        "memsize": "480",
        "numvcpus": "1"
      }
    }
  ],

Don Ky

unread,
Feb 26, 2014, 3:13:37 PM2/26/14
to packe...@googlegroups.com
FYI, I just downloaded 0.5.2 and the uploader works fine.  Just ran a build. 

Pierre Klovsjö

unread,
Feb 26, 2014, 3:49:33 PM2/26/14
to packe...@googlegroups.com
YEAAAAH, It works!!!

Time to get dirty now with customization and see if i can reproduce VMs in the same way as with kickstart/templates!

I really have to go through the JSON file(s) that i have been trying to use and figure out how things work.

Thanks a lot for your time in this Don Ky, really appreciate it!

Rgds,
Pierre

bcor...@thoughtworks.com

unread,
Mar 6, 2014, 11:12:19 AM3/6/14
to packe...@googlegroups.com
Pierre,

I'm having a similar issue. I've changed my configs to closely match Don Ky but I'm still not successful.  Do you remember what you changed to get it to work?

Here are my pastebins:

Don Ky

unread,
Mar 6, 2014, 11:38:45 AM3/6/14
to packe...@googlegroups.com
Your builder also has some strange stuff in it:

Not sure what this is:

  • "remote_datastore": "NAME",
      "remote_host": "FQDN",
      "remote_password": "PASSWORD",
      "remote_type": "esx5",
      "remote_username": "NAME",

This looks like pieces of the ESXi builder.  Doesn't match my builder example at all. We aren't building on esxi but building on vmware fusion then uploading the box to vsphere. 

Don Ky

unread,
Mar 6, 2014, 11:42:45 AM3/6/14
to packe...@googlegroups.com
Please refer to my working template here:

Ben Cornelius

unread,
Mar 6, 2014, 12:55:11 PM3/6/14
to packe...@googlegroups.com
Yup it's the esxi builder.  Apparently you don't need to run the post-processor to upload to ESXi, it just stays there.  That's my mistake for thinking it's required.  Thanks for the input, definitely helped where I messed up.


--
You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/5HVDhQHPpX0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Ben Cornelius
Sr Linux Administrator
Thoughtworks | Chicago | TechOps
Reply all
Reply to author
Forward
0 new messages