packer + vmware esxi: re-utilize iso already in datastore (instead of re-upload with every build)

1,944 views
Skip to first unread message

Alejandro

unread,
Jul 19, 2016, 10:35:48 PM7/19/16
to Packer
Hi everyone,

I am testing packer and so far is a great tool!

I managed to make it work with vCenter(esxi) 5.5 and 6 with no problems. One issue that I would like to ask you all is about re-using the iso that is already in the datastore.

With every build it takes around 10 minutes total (from enter build command to finish) but it takes around 4 minutes to "upload" the dvd iso to the datastore. Is it possible to tell packer to just use the one that is already there?

This is my json file:

{
   
"builders": [
       
{
           
"type": "vmware-iso",
           
"format": "ovf",
           
"vm_name": "PACKERTEST02",
           
"iso_url": "/rhel-server-7.2-x86_64-dvd.iso",
           
"iso_checksum": "03f3a0291634335f6995534d829bd21ffaa0d000004dfeb1b2fb81052d64a4d5",
           
"iso_checksum_type": "sha256",
           
"disk_size": "104761",
           
"disk_type_id": "thin",
           
"remote_host": "esxi-host",
             
"remote_datastore": "nas",
             
"remote_username": "root",
             
"remote_password": "********",
             
"remote_type": "esx5",
           
"ssh_username": "vagrant",
           
"guest_os_type": "rhel6-64",
           
"ssh_password": "vagrant",
           
"ssh_port": 22,
           
"ssh_wait_timeout": "20m",
           
"shutdown_command": "sudo -S /sbin/halt -h -p",
           
"headless": "false",
           
"floppy_files": [
                 
"kickstart/rhel7-packertest02.ks.cfg"
           
],
           
"boot_command": "<esc> linux inst.text inst.ks=hd:fd0:/rhel7-packertest02.ks.cfg <enter><wait>",
           
"boot_wait": "5s",
           
"keep_registered": "true",
           
"vmx_data": {
               
"config.version": 8,
               
"virtualHW.version": 8,
               
"ethernet0.virtualDev": "vmxnet3",
               
"ethernet0.networkName": "VM Network",
               
"ethernet0.addressType": "generated",
               
"ethernet0.present": "TRUE",
               
"ethernet1.virtualDev": "vmxnet3",
               
"ethernet1.networkName": "VLAN100",
               
"ethernet1.addressType": "generated",
               
"ethernet1.present": "TRUE",
               
"ethernet0.pciSlotNumber": "192",
               
"ethernet1.pciSlotNumber": "224",
               
"memsize": "2048",
               
"numvcpus": "2",
               
"cpuid.coresPerSocket": "1",
               
"RemoteDisplay.vnc.enabled": "TRUE",
               
"RemoteDisplay.vnc.port":  "5900"
           
}
       
}
   
]
}


Cheers,

Alejandro

Alvaro Miranda Aguilera

unread,
Jul 20, 2016, 1:22:46 AM7/20/16
to packe...@googlegroups.com
can you delete the iso and take the time?

it shouldnt upload twice, what can happen is too slow to check the md5/sha1 sum

other option is once you build a minimal image, you use vmware-vmx and build from an existing vm.

as time permits, can you have a look ?

Thanks
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/36d32bd5-c9e4-4602-9a3b-309e5230a53a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alejandro

unread,
Jul 20, 2016, 6:09:02 AM7/20/16
to Packer
Hi Alvaro,

thanks for your quick reply. Yes, you are correct indeed:

...
2016/07/20 18:41:01 packer: 2016/07/20 18:41:01 Verifying checksum of /vmfs/volumes/nas/packer_cache/rhel-server-7.2-x86_64-dvd.iso
2016/07/20 18:41:01 packer: 2016/07/20 18:41:01 opening new ssh session
2016/07/20 18:41:01 packer: 2016/07/20 18:41:01 starting remote command: sha256sum -c
2016/07/20 18:45:00 packer: 2016/07/20 18:45:00 remote command exited with '0': sha256sum -c
2016/07/20 18:45:00 packer: 2016/07/20 18:45:00 Initial checksum matched, no upload needed.
2016/07/20 18:45:00 ui: ==> vmware-iso: Creating virtual machine disk
...

Next week I will try to upload a smaller iso and also play with with different checksums to see which one takes less time and let you all know.

Is it possible to skip the checksum altogether?

This is looking veeery good!!

Cheers,

Alejandro

Alvaro Miranda Aguilera

unread,
Jul 20, 2016, 6:16:46 AM7/20/16
to packe...@googlegroups.com

On Wed, Jul 20, 2016 at 10:09 PM, Alejandro <alejandro...@gmail.com> wrote:
iso_checksum_type": "sha256",

Hello,


not recommended,  but the option is there. :)



iso_checksum_type (string) - The type of the checksum specified iniso_checksum. Valid values are "none", "md5", "sha1", "sha256", or "sha512" currently. While "none" will skip checksumming, this is not recommended since ISO files are generally large and corruption does happen from time to time.

Alvaro.

Alejandro

unread,
Jul 20, 2016, 8:04:16 AM7/20/16
to Packer
excelente!

Will try tomorrow.

Cheers,

Alejandro

Alejandro

unread,
Jul 21, 2016, 11:46:23 PM7/21/16
to Packer
cool, I've made the modification you recommended and also a few more ([0] remove ovftool) and now it takes 4 minutes from start-finish. :D
I can probably reduce even more if I polish the kickstart file, but is ok for now.

About checksum, since I am using jenkins+ansible, then I will create a job to periodically check for checksums (probably 1 every 24hs).

[0] https://github.com/mitchellh/packer/issues/3087
Reply all
Reply to author
Forward
0 new messages