Code Monkey home page Code Monkey logo

packer-builder-vsphere's Introduction

Team project GitHub latest release GitHub downloads TeamCity build status

Deprecation notice

This plugin was merged into official Packer repository and released with Packer since version 1.5.2.

Please use modern version of Packer and report problems, feature suggestions to main Packer repository.

This repository left for history and archived.

Packer Builder for VMware vSphere

This a plugin for HashiCorp Packer. It uses native vSphere API, and creates virtual machines remotely.

vsphere-iso builder creates new VMs from scratch. vsphere-clone builder clones VMs from existing templates.

  • VMware Player is not required.
  • Official vCenter API is used, no ESXi host modification is required.

Installation

  • Download binaries from the releases page.
  • Install the plugins, or simply put them into the same directory with JSON templates. On Linux and macOS run chmod +x on the files.

Build

Install Go and dep, run build.sh.

Or build inside a container by Docker Compose:

docker-compose run build

The binaries will be in bin/ directory.

Artifacts can be also downloaded from TeamCity builds.

Examples

See complete Ubuntu, Windows, and macOS templates in the examples folder.

Parameter Reference

Connection

  • vcenter_server(string) - vCenter server hostname.
  • username(string) - vSphere username.
  • password(string) - vSphere password.
  • insecure_connection(boolean) - Do not validate vCenter server's TLS certificate. Defaults to false.
  • datacenter(string) - VMware datacenter name. Required if there is more than one datacenter in vCenter.

VM Location

  • vm_name(string) - Name of the new VM to create.
  • folder(string) - VM folder to create the VM in.
  • host(string) - ESXi host where target VM is created. A full path must be specified if the host is in a folder. For example folder/host. See the Specifying Clusters and Hosts section above for more details.
  • cluster(string) - ESXi cluster where target VM is created. See Working with Clusters.
  • resource_pool(string) - VMWare resource pool. Defaults to the root resource pool of the host or cluster.
  • datastore(string) - VMWare datastore. Required if host is a cluster, or if host has multiple datastores.
  • notes(string) - VM notes.

VM Location (vsphere-clone only)

  • template(string) - Name of source VM. Path is optional.
  • linked_clone(boolean) - Create VM as a linked clone from latest snapshot. Defaults to false.

Hardware

  • CPUs(number) - Number of CPU sockets.
  • cpu_cores(number) - Number of CPU cores per socket.
  • CPU_limit(number) - Upper limit of available CPU resources in MHz.
  • CPU_reservation(number) - Amount of reserved CPU resources in MHz.
  • CPU_hot_plug(boolean) - Enable CPU hot plug setting for virtual machine. Defaults to false.
  • RAM(number) - Amount of RAM in MB.
  • RAM_reservation(number) - Amount of reserved RAM in MB.
  • RAM_reserve_all(boolean) - Reserve all available RAM. Defaults to false. Cannot be used together with RAM_reservation.
  • RAM_hot_plug(boolean) - Enable RAM hot plug setting for virtual machine. Defaults to false.
  • video_ram(number) - Amount of video memory in MB.
  • disk_size(number) - The size of the disk in MB.
  • network(string) - Set network VM will be connected to.
  • NestedHV(boolean) - Enable nested hardware virtualization for VM. Defaults to false.
  • configuration_parameters(map) - Custom parameters.
  • boot_order(string) - Priority of boot devices. Defaults to disk,cdrom

Hardware (vsphere-iso only)

  • vm_version(number) - Set VM hardware version. Defaults to the most current VM hardware version supported by vCenter. See VMWare article 1003746 for the full list of supported VM hardware versions.
  • guest_os_type(string) - Set VM OS type. Defaults to otherGuest. See here for a full list of possible values.
  • disk_controller_type(string) - Set VM disk controller type. Example pvscsi.
  • disk_thin_provisioned(boolean) - Enable VMDK thin provisioning for VM. Defaults to false.
  • network_card(string) - Set VM network card type. Example vmxnet3.
  • usb_controller(boolean) - Create USB controller for virtual machine. Defaults to false.
  • cdrom_type(string) - Which controller to use. Example sata. Defaults to ide.
  • firmware(string) - Set the Firmware at machine creation. Example efi. Defaults to bios.

Boot (vsphere-iso only)

  • iso_paths(array of strings) - List of datastore paths to ISO files that will be mounted to the VM. Example "[datastore1] ISO/ubuntu.iso".
  • floppy_files(array of strings) - List of local files to be mounted to the VM floppy drive. Can be used to make Debian preseed or RHEL kickstart files available to the VM.
  • floppy_dirs(array of strings) - List of directories to copy files from.
  • floppy_img_path(string) - Datastore path to a floppy image that will be mounted to the VM. Example [datastore1] ISO/pvscsi-Windows8.flp.
  • http_directory(string) - Path to a directory to serve using a local HTTP server. Beware of limitations.
  • http_ip(string) - Specify IP address on which the HTTP server is started. If not provided the first non-loopback interface is used.
  • http_port_min and http_port_max as in other builders.
  • iso_urls(array of strings) - Multiple URLs for the ISO to download. Packer will try these in order. If anything goes wrong attempting to download or while downloading a single URL, it will move on to the next. All URLs must point to the same file (same checksum). By default this is empty and iso_url is used. Only one of iso_url or iso_urls can be specified.
  • iso_checksum (string) - The checksum for the OS ISO file. Because ISO files are so large, this is required and Packer will verify it prior to booting a virtual machine with the ISO attached. The type of the checksum is specified with iso_checksum_type, documented below. At least one of iso_checksum and iso_checksum_url must be defined. This has precedence over iso_checksum_url type.
  • iso_checksum_type(string) - The type of the checksum specified in iso_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.
  • iso_checksum_url(string) - A URL to a GNU or BSD style checksum file containing a checksum for the OS ISO file. At least one of iso_checksum and iso_checksum_url must be defined. This will be ignored if iso_checksum is non empty.
  • boot_wait(string) Amount of time to wait for the VM to boot. Examples 45s and 10m. Defaults to 10 seconds. See format.
  • boot_command(array of strings) - List of commands to type when the VM is first booted. Used to initalize the operating system installer. See details in Packer docs.

Provision

  • communicator - ssh (default), winrm, or none (create/clone, customize hardware, but do not boot).
  • ip_wait_timeout(string) - Amount of time to wait for VM's IP, similar to 'ssh_timeout'. Defaults to 30m (30 minutes). See the Go Lang ParseDuration documentation for full details.
  • ip_settle_timeout(string) - Amount of time to wait for VM's IP to settle down, sometimes VM may report incorrect IP initially, then its recommended to set that parameter to apx. 2 minutes. Examples 45s and 10m. Defaults to 5s(5 seconds). See the Go Lang ParseDuration documentation for full details.
  • ssh_username(string) - Username in guest OS.
  • ssh_password(string) - Password to access guest OS. Only specify ssh_password or ssh_private_key_file, but not both.
  • ssh_private_key_file(string) - Path to the SSH private key file to access guest OS. Only specify ssh_password or ssh_private_key_file, but not both.
  • winrm_username(string) - Username in guest OS.
  • winrm_password(string) - Password to access guest OS.
  • shutdown_command(string) - Specify a VM guest shutdown command. VMware guest tools are used by default.
  • shutdown_timeout(string) - Amount of time to wait for graceful VM shutdown. Examples 45s and 10m. Defaults to 5m(5 minutes). See the Go Lang ParseDuration documentation for full details.

Postprocessing

  • create_snapshot(boolean) - Create a snapshot when set to true, so the VM can be used as a base for linked clones. Defaults to false.
  • convert_to_template(boolean) - Convert VM to a template. Defaults to false.

Working with Clusters

Standalone Hosts

Only use the host option. Optionally specify a resource_pool:

"host": "esxi-1.vsphere65.test",
"resource_pool": "pool1",

Clusters Without DRS

Use the cluster and host parameters:

"cluster": "cluster1",
"host": "esxi-2.vsphere65.test",

Clusters With DRS

Only use the cluster option. Optionally specify a resource_pool:

"cluster": "cluster2",
"resource_pool": "pool1",

Required vSphere Permissions

  • VM folder (this object and children):
    Virtual machine -> Inventory
    Virtual machine -> Configuration
    Virtual machine -> Interaction
    Virtual machine -> Snapshot management
    Virtual machine -> Provisioning
    
    Individual privileges are listed in #97 (comment).
  • Resource pool, host, or cluster (this object):
    Resource -> Assign virtual machine to resource pool
    
  • Host in clusters without DRS (this object):
    Read-only
    
  • Datastore (this object):
    Datastore -> Allocate space
    Datastore -> Browse datastore
    Datastore -> Low level file operations
    
  • Network (this object):
    Network -> Assign network
    
  • Distributed switch (this object):
    Read-only
    

For floppy image upload:

  • Datacenter (this object):
    Datastore -> Low level file operations
    
  • Host (this object):
    Host -> Configuration -> System Management
    

packer-builder-vsphere's People

Contributors

amarruedo avatar clingle avatar dtretyakov avatar jcoconnor avatar lizatretyakova avatar mkuzmin avatar pragmaspark avatar remijouannet avatar rgl avatar scbjans avatar seanmalloy avatar tsborland avatar vladrassokhin avatar xosmig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-builder-vsphere's Issues

winrm_username and password

Hello,

I am trying to create a windows image using the vsphere plugin, but I wasn't able to do that since ssh is mandatory. Is there any workaround or plan to add windows support?
"winrm_username": "Administrator",
"winrm_password": "{{user guest_password}}",

Kind Regards,
Makram.

Build 'vsphere' errored: NotAuthenticated

Hello, guys!
We are using your plugin to clone VM's and provision them at vSphere 6.5.
Faced up with situation when our job fails with error:

==> vsphere: Executing shutdown command...
packer-builder-vsphere: 2017/08/09 08:04:47 Shutdown command: sudo shutdown -h now
packer-builder-vsphere: 2017/08/09 08:04:47 opening new ssh session
packer-builder-vsphere: 2017/08/09 08:04:47 starting remote command: sudo shutdown -h now
packer-builder-vsphere: 2017/08/09 08:04:47 Waiting max 5m0s for shutdown to complete
==> vsphere: Power off VM...
==> vsphere: NotAuthenticated
==> vsphere: Destroying VM...
==> vsphere: ServerFaultCode: The session is not authenticated.
[INFO] (telemetry) ending vsphere
[INFO] (telemetry) found error: NotAuthenticated
Build 'vsphere' errored: NotAuthenticated

VM clearly shutdown and stays at vSphere (its fine, but our job fails with error). So plugin cannot destroy VM due to not authenticated session also.

Our job takes 3.5 hours usually. So, when we shortened our task to 25 min just for test - it succeed. With any long-duration tries - failed.

I found an article at vmware.com saying that we can increase timeout constraints at vSphere to resolve this:
https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2040626
It didn't help us. So I want to ask you, could you add some kind of Keep Alive packets during the job? Or reestablish session to vSphere at the end of the job?

Sure, this will fix this issue.

Configure CPU reservation

Hardware customization options

  • Reserve CPU in MHz
  • Limit CPU in MHz
  • Reserve CPU cores (HT Sharing)

Detect datastore automatically

A target host has a single datastore, so it can be resolved automatically.
At the moment the builder fails with

Build 'vsphere-clone' errored: default datastore resolves to multiple instances, please specify

Because a datacenter has more datastores on other hosts.

Issue with setting up a minimal example - Step "StepCloneVM" failed

I've created a template on vcenter called win-base with which the builder is referencing, and I can't seem to debug the issue which the error is referencing.

packer -version
1.1.1

Template.json:

{
	"builders": [
		{
			"type": "vsphere",

			"vcenter_server": "srv.company.com",
			"username": "[email protected]",
			"password": "fake_passw&rd1!",
			"insecure_connection": true,

			"template": "win-base",
			"vm_name": "vm-1",
			"host": "Production/esx-host.company.com",
			"datastore": "datastore01",

			"ssh_username": "root",
			"ssh_password": "secret"
		}
	],

	"provisioners": [
		{
			"type": "shell",
			"inline":[ "echo hello" ]
		}
	]
}

Error:

...
2017/10/17 09:45:50 ui: vsphere output will be in this color.
2017/10/17 09:45:50 ui: 
2017/10/17 09:45:50 Build debug mode: true
2017/10/17 09:45:50 Force build: true
2017/10/17 09:45:50 On error: abort
2017/10/17 09:45:50 Preparing build: vsphere
Debug mode enabled. Builds will not be parallelized.
vsphere output will be in this color.

2017/10/17 09:45:50 Debug enabled, so waiting for build to finish: vsphere
2017/10/17 09:45:50 Starting build run: vsphere
2017/10/17 09:45:50 Running builder: vsphere
2017/10/17 09:45:50 [INFO] (telemetry) Starting builder vsphere
2017/10/17 09:45:55 ui: ask: ==> vsphere: Pausing after run of step 'StepConnect'. Press enter to continue.
==> vsphere: Pausing after run of step 'StepConnect'. Press enter to continue. 
2017/10/17 09:45:56 ui: ==> vsphere: Cloning VM...
==> vsphere: Cloning VM...
2017/10/17 09:45:56 ui error: ==> vsphere: Step "StepCloneVM" failed, aborting...
==> vsphere: Step "StepCloneVM" failed, aborting...
Build 'vsphere' errored: unexpected EOF

==> Some builds didn't complete successfully and had errors:
--> vsphere: unexpected EOF

==> Builds finished but no artifacts were created.
2017/10/17 09:45:56 [INFO] (telemetry) ending vsphere
2017/10/17 09:45:56 [INFO] (telemetry) found error: unexpected EOF
2017/10/17 09:45:56 ui error: Build 'vsphere' errored: unexpected EOF
2017/10/17 09:45:56 Waiting on builds to complete...
2017/10/17 09:45:56 Builds completed. Waiting on interrupt barrier...
2017/10/17 09:45:56 machine readable: error-count []string{"1"}
2017/10/17 09:45:56 ui error: 
==> Some builds didn't complete successfully and had errors:
2017/10/17 09:45:56 machine readable: vsphere,error []string{"unexpected EOF"}
2017/10/17 09:45:56 ui error: --> vsphere: unexpected EOF
2017/10/17 09:45:56 ui: 
==> Builds finished but no artifacts were created.
2017/10/17 09:45:56 [INFO] (telemetry) Finalizing.
2017/10/17 09:45:56 /Users/username/.packer.d/plugins/packer-builder-vsphere: plugin process exited
2017/10/17 09:45:56 waiting for all plugin processes to complete...
2017/10/17 09:45:56 /usr/local/bin/packer: plugin process exited

Any suggestions would be greatly appreciated!

Post-Processors export template

Hello,

Is there a way to export the created template via packer vsphere plugin in post-processing as binary (ova, ovf, ...)?
...
"post-processors":[
{
"type": "compress",
"output": "bundle.zip"
}
]

Kind Regards,
Makram.

The session is not authenticated - timeout

if the packer script takes longer than 60 minutes the authentication seems to timeout for vsphere

2017/08/18 09:38:00 [INFO] (telemetry) ending powershell
1503049080,,ui,say,==> vsphere: Shut down VM...
1503049081,,ui,say,==> vsphere: Power off VM...
1503049086,,ui,error,==> vsphere: NotAuthenticated
1503049086,,ui,say,==> vsphere: Destroying VM...
1503049087,,ui,error,==> vsphere: ServerFaultCode: The session is not authenticated.
2017/08/18 09:38:07 [INFO] (telemetry) ending vsphere
2017/08/18 09:38:07 [INFO] (telemetry) found error: Cannot shut down VM: ServerFaultCode: The session is not authenticated.
1503049087,,ui,error,Build 'vsphere' errored: Cannot shut down VM: ServerFaultCode: The session is not authenticated.
1503049087,,error-count,1
2017/08/18 09:38:07 Builds completed. Waiting on interrupt barrier...
1503049087,,ui,error,\n==> Some builds didn't complete successfully and had errors:
1503049087,vsphere,error,Cannot shut down VM: ServerFaultCode: The session is not authenticated.
1503049087,,ui,error,--> vsphere: Cannot shut down VM: ServerFaultCode: The session is not authenticated.
1503049087,,ui,say,\n==> Builds finished but no artifacts were created.
2017/08/18 09:38:07 [WARN] (telemetry) Error finalizing report. This is safe to ignore. Post https://checkpoint-api.hashicorp.com/v1/telemetry/packer: context deadline exceeded
2017/08/18 09:38:07 waiting for all plugin processes to complete...
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /tmp/build/e55deab7/packer-builder-vsphere.linux: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
2017/08/18 09:38:07 /usr/local/bin/packer: plugin process exited
/tmp/build/e55deab7/bosh-windows-stemcell-builder/lib/stemcell/builder/base.rb:53:in `run_packer': Stemcell::Builder::PackerFailure (Stemcell::Builder::PackerFailure)
	from ci/tasks/create-vsphere-stemcell/create-vsphere-stemcell.rb:6:in `build'
	from ci/tasks/create-vsphere-stemcell/create-vsphere-stemcell.rb:64:in `<main>'

Allow user to specify a force to override an existing template with this new build

When creating a new build using the plugin - it would be useful to allow Packer to override the output. Either by renaming the old one to a previous build ID or deleting it?

How I use this? I pass a static template name to Ansible's vmware_guest module to build a new build VM.

Unless I can detect the creation of my template that packer just made, then I would prefer if it was handled smartly.

Clusters are not supported

since the latest version i get the error:

2017/09/13 13:42:55 [INFO] (telemetry) found error: path '/Interxion MAD2/host/cluster1' resolves to multiple hosts
1505310175,,ui,error,Build 'vsphere' errored: path '/Interxion MAD2/host/cluster1' resolves to multiple hosts

seems to be an issues with the HostSystem option as this does such checks

h, err := d.finder.HostSystem(d.ctx, fmt.Sprintf("/%v/host/%v", d.datacenter.Name(), name))

it worked on v.1.3.1.dev1 & v.1.3

maby a possibility to release 1.3.1?? as it seems you have removed v.1.3.1.dev1

Support datastoreclusters

I would like to propose support of datastoreclusters. In our use case datastores are grouped in datastoreclusters akin to how clusters are used to group hosts. In our other vSphere related automation (i.e bootstrapping VMs based on templates) we already make use of a datastorecluster parameter, where we let vSphere decide on which datastore to place it.

This feature would make the datastore and datastorecluster parameter mutually exclusive since in case of the latter vSphere's DRS takes care of suggesting a fitting datastore inside the specified datastorecluster based on the size of all disks present inside the template.

Output of govc find . -type s:

/DC/datastore/DC1EXP01/xpaa_vi_215
/DC/datastore/DC1EXP01/xpaa_vi_217
/DC/datastore/DC1EXP01/xpaa_vi_219
/DC/datastore/DC1EXP01/xpaa_vi_221

Let me know if there is interest in this type of functionality and whether you consider a PR for this since I have this part working for the iso builder already based on govc's create inside the vm package. PR would of course include full support with clone and am sure will work with #68 as well (feature I'm looking forward to).
See usage of the recommendDatastore function in create.go#L333 and declare in create.go#L455. I found this usage fitting quite nicely with this existing codebase, so all credit goes to them :).

Issue with installing plugin

Hi,

Having an issue with installing the plugin on MacOS (with which packer was installed via brew).

I've downloaded the packer-builder-vsphere.macos and placed it in ~/.packer.d/plugins/packer-builder-vsphere.macos.

(I've also tried renaming it without the .macos).

Running with PACKER_LOG=1, packer manages to discover the plugin:

[INFO] Packer version: 1.1.1
Packer Target OS/Arch: darwin amd64
Built with Go Version: go1.9.1
Detected home directory from env var: /Users/username
[DEBUG] Discovered plugin: vsphere = /Users/username/.packer.d/plugins/packer-builder-vsphere

And then later on:

2017/10/16 16:31:46 Detected home directory from env var: /Users/username
2017/10/16 16:31:46 Setting cache directory: /Users/username/builds/0/packer_cache
2017/10/16 16:31:46 Detected home directory from env var: /Users/username
2017/10/16 16:31:46 Loading builder: vsphere
2017/10/16 16:31:46 Plugin could not be found. Checking same directory as executable.
2017/10/16 16:31:46 Current exe path: /usr/local/bin/packer
2017/10/16 16:31:46 Creating plugin client for path: /usr/local/bin/packer-builder-vsphere
2017/10/16 16:31:46 Starting plugin: /usr/local/bin/packer-builder-vsphere []string{"/usr/local/bin/packer-builder-vsphere"}
2017/10/16 16:31:46 ui error: Failed to initialize build 'vsphere': error initializing builder 'vsphere': fork/exec /usr/local/bin/packer-builder-vsphere: no such file or directory
2017/10/16 16:31:46 ui: vsphere output will be in this color.
2017/10/16 16:31:46 ui: 
2017/10/16 16:31:46 Build debug mode: false
2017/10/16 16:31:46 Force build: true
2017/10/16 16:31:46 On error: abort
2017/10/16 16:31:46 Waiting on builds to complete...
2017/10/16 16:31:46 Builds completed. Waiting on interrupt barrier...
2017/10/16 16:31:46 ui: 
==> Builds finished but no artifacts were created.
2017/10/16 16:31:46 [INFO] (telemetry) Finalizing.
Failed to initialize build 'vsphere': error initializing builder 'vsphere': fork/exec /usr/local/bin/packer-builder-vsphere: no such file or directory
vsphere output will be in this color.


==> Builds finished but no artifacts were created.
2017/10/16 16:31:47 waiting for all plugin processes to complete...

Any ideas what I could be doing wrong? Do I need to change the permissions of the packer-builder-vsphere.macos?

Thanks!

Resize disks

Additional hardware customization option: increase HDD size

Resource pools not found

Hi,

When trying to build a template from ISO (vSphere 6.0), the Resource Pool specified in the JSON file is not found by packer;

Build 'vsphere-iso' errored: error creating vm: resource pool '[hostname-redacted]
/Resources/[resource-pool-redacted]' not found

Packer is authenticating against vSphere, and the Datacenter name is set correctly. Is there an option to set the Cluster name? I think this worked on MacOS a day or two ago.

packer version: 1.2.1
plugins: 2.0-beta4
OS: Centos 7.

Let me know if you need further info/debug.

Clone from templates

if a source VM is a template
screen shot 2017-05-08 at 18 18 39

then builds fail with an error:

==> vsphere: start cloning...
Build 'vsphere' errored: A specified parameter was not correct. 
spec.location.pool

template tags

Not really an issue more of a question

Is there any way to assign tags to the templates in a similar way that you can with the AWS builder using this plug in?

Replace Existing Template with Same Name

Hi,

Could you add a feature allowing replacement of the template if it already exists? It'd be easier than having to delete the template via vsphere client before building a new one.

Thanks

Error removing floppy and cdroms when convert_to_template is set to true

I'm creating an Ubuntu machine based on the example you provide.

When I set convert_to_template to true, I get the following error:

==> vsphere-iso: Shut down VM...
==> vsphere-iso: VM stopped
==> vsphere-iso: Convert VM into template...
==> vsphere-iso: error removing floppy: The operation is not supported on the object.
==> vsphere-iso: error removing cdroms: The operation is not supported on the object.
Build 'vsphere-iso' finished.

I guess that the builder is trying to remove both floppy and cdroms from a virtual machine template, which is not possible. It should try to do the removing prior to converting the virtual machine to a template.

I've had a look to the code and maybe a solution to this could be to move the logic of removing the devices to separate steps,StepRemoveCDRomand StepRemoveFloppy, leaving the Cleanup functions of StepAddFloppyand StepAddCDRomempty. This way this new steps could be placed prior to StepCreateSnapshot and StepConvertToTemplate.

If you consider this a good solution I can PR it.

Convert 'url' option to 'vcenter_server'

At the moment vCenter connection is configured by "url": "https://vcenter.vsphere5.test/sdk" option. This is too complex and confusing.

Need to hardcode https and sdk pieces, so the setting looks like "vcenter_server": "vcenter.vsphere5.test"

Set static network settings by VM customization

I am deploying a vm on a vsphere environment using packer-builder-vsphere . here the challenge is vm gets cloned ,powered on and stucks at " waiting for ip " . Is there any option to skip this as my environment doesnt have any dhcp server . Can we skip this or assign a static ip .Please guide on any options on the concern

Cannot destroy VM if shutdown stucks

If shutdown is started, but isn't finished in time (halted for some reason, or timeout is too small) then VM stucks in intermediate state:
It's powered on, but cannot be powered off.

==> vsphere: Executing shutdown command...
==> vsphere: Power off VM...
==> vsphere: The attempted operation cannot be performed in the current state (Powered off).
==> vsphere: Destroying VM...
==> vsphere: The attempted operation cannot be performed in the current state (Powered on).
Build 'vsphere' errored: Timeout while waiting for machine to shut down.

Support for Windows Templates?

Good afternoon,

Will this work with Windows Templates within vSphere? i noticed that the ssh_username is mandatory - which leads me to believe that we cannot use a Windows template as the source. From a VMware perspective though it shouldn't need the u/p to do the cloning procedure. Obviously the provisioner will need access to run any scripts (powershell) after the fact.

Thank you,

Adam

Failed to initialize build 'vsphere'

I am trying to use the vsphere plugin within a Jenkins job along with the Packer Jenkins plugin. I download the plugin and chmod the plugin as described (as a build - execute shell - command). However Packer throws an error when running:

Failed to initialize build 'vsphere': error initializing builder 'vsphere': fork/exec /var/lib/jenkins/jobs/accosia2/workspace/packer-builder-vsphere.linux: exec format error

Jenkins 2.89.4
Packer 1.1.2
vsphere-builder 1.6

Convert VMs to templates

After a VM is created and provisioned, we need a last step: prepare it for long-term usage: as a source in other Packer builds, in Terraform plans, as TeamCity cloud agents.

we need two additional options (independent, disabled by default):

  1. to allow linked cloning, a new snapshot should be added
  2. base images are usually converted from VMs to templates

Pre-seed file and vSphere 6.0

Ran into an issue where the boot_command section does not work against our vSphere environment (6.0).

`Build 'vsphere-iso' errored: error typing a boot command: ServerFaultCode: Unable to resolve WSDL method name PutUsbScanCodes for namespace name urn:vim25

while parsing SOAP body
at line 2, column 60

while parsing SOAP envelope
at line 2, column 0

while parsing HTTP request before method was determined
at line 1, column 0`

Looks like this method was not present in the API until vSphere 6.5. Any workarounds? I added this but it doesn't seem to work (hoping the machine would boot from floppy)

"floppy_files": [
"./scripts/ubuntu/preseed.cfg"
],

Wait for graceful VM shutdown

  • shutdown_command parameter is not specified.
  • VM is provisioned successfully
  • Shutdown is started

Immediately after that, power off action is called.
VM disk is left in inconsistent state.

We need to wait until VM is moved to power off state itself.

Support 'boot_command` on vSphere 6.0 and older

Hello, I am encountering a error when trying to run a centos 7 automated install. It fails at typing the boot command with the following message:

[root@oraclebench packer]# ./packer build centos7.json
vsphere-iso output will be in this color.

==> vsphere-iso: Creating VM...
==> vsphere-iso: Adding CDRoms...
==> vsphere-iso: Creating floppy disk...
    vsphere-iso: Copying files flatly from floppy_files
    vsphere-iso: Copying file: ks.cfg
    vsphere-iso: Done copying files from floppy_files
    vsphere-iso: Collecting paths from floppy_dirs
    vsphere-iso: Resulting paths from floppy_dirs : []
    vsphere-iso: Done copying paths from floppy_dirs
==> vsphere-iso: Uploading created floppy image
==> vsphere-iso: Adding generated Floppy...
==> vsphere-iso: Adding configuration parameters...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting 10s for boot...
==> vsphere-iso: Typing boot command...
==> vsphere-iso: Power off VM...
==> vsphere-iso: Destroying VM...
Build 'vsphere-iso' errored: error typing a boot command: ServerFaultCode: Unable to resolve WSDL method name PutUsbScanCodes for namespace name urn:vim25

while parsing SOAP body
at line 2, column 60

while parsing SOAP envelope
at line 2, column 0

while parsing HTTP request before method was determined
at line 1, column 0

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso: error typing a boot command: ServerFaultCode: Unable to resolve WSDL method name PutUsbScanCodes for namespace name urn:vim25

while parsing SOAP body
at line 2, column 60

while parsing SOAP envelope
at line 2, column 0

while parsing HTTP request before method was determined
at line 1, column 0

==> Builds finished but no artifacts were created.
--------------------------------------------------------------------------------------------

this is the centos7.json file for building:

{
  "builders": [
    {
      "boot_command": [
        "<up><wait><tab> text inst.ks=hd:fd0:/ks.cfg <enter>"
      ],
      "type": "vsphere-iso",

      "vcenter_server":      "server",
      "username":            "user",
      "password":            "password",
      "insecure_connection": "true",
      "ssh_username": "root",
      "ssh_password": "example",

      "datacenter": "test",
      "cluster": "test",
      "network": "test",
      "network_card": "vmxnet3",
      "datastore": "test",
      "vm_name": "golden_image_lin",
      "guest_os_type": "rhel7_64Guest",

      "CPUs":             2,
      "RAM":              4096,
      "RAM_reserve_all": true,

      "disk_controller_type":  "pvscsi",
      "disk_size":        50,
      "disk_thin_provisioned": true,
      "folder": "_directory",

      "iso_paths": [
        "[ISO] place/centos7-netinstall.iso"
      ],
      "floppy_files": [
        "ks.cfg"
      ],
      "boot_order": "disk,cdrom"
    }
  ]
}

what am I doing wrong or is this a issue?
debug mode is not showing anything weird....

Support for more than one disk

We would like to use this awesome plugin to build new templates on vSphere, which is currently a manual process. However, all our current templates use more than one disk, which is not supported at the moment.

Is support for multiple disks on the roadmap? I am thinking of an option such as disk_additional_size from the Packer vmware-iso builder.

If there are no plans to implement this, I will try to write the code myself. Would you accept patches to include this feature?

Thanks,
Tim

Are resource pools mandatory to have on the vsphere server?

While not setting a resource_pool in the builder settings, and not have a resource pool on the vsphere host, I have the following error:

Build 'vsphere' errored: resource pool '/Data Center/host/Production/esxi-server/Resources/' not found

Any ideas?

Build VM from ISO file

It would be great if it was possible to use an ISO file as source instead of having to clone a VM (the vmware-iso builder does not support the vSphere API)

resource pool not found

we have no resource pool defined in our vsphere because drs is not enabled
as i'm reading your documentation resource_pool - by default a root of vSphere host.
a resource pool seems not mandatory.

can you please elaborate on this?

1502442765,,ui,say,==> vsphere: Cloning VM...
1502442783,,ui,error,Build 'vsphere' errored: resource pool '/Interxion MAD2/host/10.xx.111.xxx/Resources/' not found
1502442783,,error-count,1
1502442783,,ui,error,\n==> Some builds didn't complete successfully and had errors:
1502442783,vsphere,error,resource pool '/Interxion MAD2/host/10.x.111.xxx/Resources/' not found
1502442783,,ui,error,--> vsphere: resource pool '/Interxion MAD2/host/10.xx.111.xxx/Resources/' not found
1502442783,,ui,say,\n==> Builds finished but no artifacts were created.

json:

          {
            "type" => "vsphere",
            "vcenter_server" => Stemcell::Builder::validate_env('VCENTER_SERVER'),
            "username" => Stemcell::Builder::validate_env('VCENTER_USERNAME'),
            "password" => Stemcell::Builder::validate_env('VCENTER_PASSWORD'),
            "insecure_connection" => true,

            "template" => Stemcell::Builder::validate_env('BASE_TEMPLATE'),
            "folder" => Stemcell::Builder::validate_env('VCENTER_VM_FOLDER'),
            "vm_name" =>  "packer-vmx-#{Time.now.getutc.to_i}",
            "host" =>     Stemcell::Builder::validate_env('VCENTER_HOST'),

            "ssh_username" => 'Administrator',
            "ssh_password" => Stemcell::Builder::validate_env('ADMINISTRATOR_PASSWORD'),
            "CPUs" => ENV.fetch('MEM_SIZE', '4096'),
            "RAM"  => ENV.fetch('NUM_VCPUS', '4')
          }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.