Giter Site home page Giter Site logo

vagrant-vmware-esxi's People

Contributors

bby-bishopclark avatar cbanu-keysight avatar dakota avatar dezull avatar egandro avatar jbeker avatar josenk avatar kranich avatar misteriosojo avatar rgl avatar scaleoutsean avatar strasharo avatar thenotary 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

vagrant-vmware-esxi's Issues

can't rerun vagrant up after vagrant destroy

I can't run vagrant up after I run vagrant destroy. I'm getting this error message:

Error: Duplicate name 'builder-ubuntu-1604.vagrantup.com' on target. Use --overwrite option to delete it.
STDERR: There was an OVF Tool error.

it seems that this driver plugin doesn't clean the VM on the ESXi server when I call vagrant destroy.

Feature Request: Specify Diskstore folder

Apologies if I've missed this option and it is already an existing feature.

I've identified the esxi.esxi_disk_store = "store" command.

However, this places the vagrant-created boxes in the root location. I'd like them all to exist under a vagrant folder.

Would it be possible to have an option like:

esxi.esxi_disk_store_folder = "vagrant"

Cheers,
Don

Add linked_clone support

It would be really nice to support linked_clone as it greatly shortens the deployment time.

config.vm.provider 'vmware_esxi' do |esxi|
  esxi.linked_clone = true
...

With only 1 virtual_network defined, unable to push static IPs

Hi,

I am trying to bring up a VM and give it a static IP

Vagrantfile

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
  config.vm.define test-vm do |x|
    x.vm.box = "bento/ubuntu-16.04"
    x.vm.network "private_network", ip: "10.73.40.201"  ===> Desired static IP
    x.vm.provider :vmware_esxi do |v|
      v.esxi_hostname = '10.73.40.19'
      v.esxi_username = 'root'
      v.esxi_password = 'secret'
      v.custom_vmx_settings = [['vhv.enable', 'TRUE']]
      v.vmname = test-vm
      v.memsize = 6000
      v.numvcpus = 2
      v.virtual_network = ["VM Network"]  ===> 1 virtual network defined
      v.debug = 'true'
      v.allow_overwrite = 'True'
    end
  end
end

When I do a vagrant up and then log in to the VM , I see that the IP assigned to it is via dhcp

Console logs

Bringing machine 'test-vm' up with 'vmware_esxi' provider...
==> test-vm: Virtual Machine will be built.
Available DS Volumes: ["datastore1"]
Available Networks: ["VM Network", "Management Network"]
guestvm_network[0]: VM Network
==> test-vm: ---
==> test-vm: --- ESXi host       : 10.73.40.19
==> test-vm: --- VM Name         : test-vm
==> test-vm: --- Box             : bento/ubuntu-16.04
==> test-vm: --- Box Ver         : 201801.02.0
==> test-vm: --- Disk Store      : datastore1
==> test-vm: --- CPUS            : 2
==> test-vm: --- Memsize (MB)    : 6000
==> test-vm: --- Guest OS type   : ubuntu-64
==> test-vm: --- Virtual Network : ["VM Network"]
==> test-vm: --- Allow Overwrite : True
==> test-vm: --- Resource Pool   :
VMware ovftool 4.2.0 (build-5965791)
ovftool command: ovftool --noSSLVerify --overwrite --powerOffTarget  --net:"net0=VM Network" -dm=thin  -ds="datastore1" --name="test-vm" "/home/username/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-vm.vmx" vi://root:******@10.73.40.19
Opening VMX source: /home/username/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-vm.vmx
Enter login information for target vi://10.73.40.19/
Username: root
Password: **********
Enter login information for target vi://10.73.40.19/
Username: root
Password: **********
Opening VI target: vi://[email protected]:443/
Deploying to VI: vi://[email protected]:443/
Transfer Completed
Completed successfully
Keeping file: /home/username/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-vm.vmx
==> test-vm: --- VMID: 86
==> test-vm: --- Custom vmx      : Append vhv.enable = "TRUE"
==> test-vm: --- VM has been Powered On...
==> test-vm: --- Waiting for state "running"
==> test-vm: --- Success, state is now "running"
num adapters: 1,  vm.network.count: 1
    test-vm:
    test-vm: Vagrant insecure key detected. Vagrant will automatically replace
    test-vm: this with a newly generated keypair for better security.
    test-vm:
    test-vm: Inserting generated public key within guest...
    test-vm: Removing insecure key from the guest if it's present...
    test-vm: Key inserted! Disconnecting and reconnecting using new SSH key...
==> test-vm: Rsyncing folder: /home/username/ => /vagrant

Now I assumed that the VM would have its IP 10.73.40.201 instead I see that it has 10.73.40.50

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:93:e1:f5 brd ff:ff:ff:ff:ff:ff
    inet 10.73.40.50/23 brd 10.73.41.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe93:e1f5/64 scope link
       valid_lft forever preferred_lft forever

Is it a mandate to define multiple virtual networks ?

Thanks,
Shashank

Ability to deploy same box to multiple ESXi

First of all thank you for great plugin, it makes the ESXi provisioning so much easier.

I have been using it to provision on multiple ESXi servers and I realised that may be there is a nice feature/improvement that can be done. So here is the use case,

Let's suppose, I want to deploy a VM to 10 ESXi servers (may be docker host, or replicas of another service). The base VM is the same for all the destination ESXi servers, it has pretty much same configuration (CPU/Mem/Disk etc). The way the plugin works right now is that it will create a vApp for each ESXi separately and deploy it to ESXi servers. This works, however it fails most of the time when the number of destination ESXi servers is a lot (I have had high failure rate with 8).

By disabling parallel provision on Vagrant, it makes the same process even more slower, however this has good success rate.

My ask is, if the plugin could detect (with a flag/automatically), that as long as Base Box is same for a group of ESXi servers, then the vApp should only be build once. This will great, because the .vmx is is already customizable. I think this will speed up the process of deploying to more than 1 ESXi servers much faster. Hope it makes sense and hope you can incorporate it as an improvement/feature.

Thank you again for the hard work.

vagrant ssh taking over 30 sec's to complete

First of all, I want to say I have found this plugin extremely useful. I am still attempting to understand everything but I am getting a bit frustrated with the time it takes to ssh into my vagrant box. It works, but waiting 30 some seconds each time is getting a little annoying. I have attached a typescript of the ssh debug from vagrant. Let me know if you need any other info.
vagrant_ssh.txt

ssh-config HostName/IP changes post running a provisioning script

Hi Jonathan,

Need some info on this issue that I have been facing. I am not entirely sure if its a plugin issue but I dont see it happening when I run the same tests on libvirt.

Vagrantfile:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
  config.vm.define test-vm do |x|
    x.vm.box = "bento/ubuntu-16.04"
    x.vm.provider :vmware_esxi do |v|
      v.esxi_hostname = '10.xx.xx.19'
      v.esxi_username = 'root'
      v.esxi_password = 'secret'
      v.custom_vmx_settings = [['vhv.enable', 'TRUE']]
      v.vmname = test-vm
      v.memsize = 6000
      v.numvcpus = 2
      v.debug = 'true'
      v.allow_overwrite = 'True'
    end
  end
end

Prior to the script that runs, following is the out of vagrant ssh-config

==> test-vm: --- ESXi version    : VMware ESXi 6.5.0 build-4887370
Host test-vm
HostName 10.xx.xx.xx   ====> The hostname 
User vagrant
Port 22
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/username/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
With this when I run vagrant ssh it does a ssh to the VM without being prompted for a password

I can directly access the vm running vagrant ssh

==> test-vm: --- ESXi version    : VMware ESXi 6.5.0 build-4887370
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64)

* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

vagrant@vagrant:~$   ===> PASSWORDLESS SSH

Now I modify the vagrant file to include a shell script that provisions my VM after it comes up.
The script does a couple of stuff, like creates some bridge network interfaces and installs some packages etc.

I modify my Vagrant file to include the following

x.vm.provision :shell do |s|
       s.path = /home/username/test.sh
    end

Post the script, vagrant ssh-config.

Host test-vm
HostName 172.18.0.1 ===> CHANGED
User vagrant
Port 22
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/username/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
Why does vagrant change the hostname. Due to this I am unable to do a passwordless ssh to the VM using 'vagrant ssh'

Now when I try to run a vagrant ssh, it asks for a password.

vagrant ssh
[email protected]'s password:  ====> PASSWORD PROMPT

I have tried the same test with libvirt and I dont run into this.
Why does the IP in the ssh-config change?

Regards

==> default: --- Disk Store : SyntaxError: invalid syntax

Vargrant Version: 2.0.1
plugin version: vagrant-vmware-esxi (1.5.0)

==> default: Virtual Machine will be built.
==> default: --- WARNING : Disk Store "vms-noc-01-local-storage-1" not found, using SyntaxError: invalid syntax
==> default: ---
==> default: --- ESXi host : 192.168.254.26
==> default: --- VM Name : V-pvr-noc-05-root-TEST_VM
==> default: --- Box : generic/centos7
==> default: --- Box Ver : 1.3.40
==> default: --- Disk Store : SyntaxError: invalid syntax
==> default: --- CPUS : 2
==> default: --- Memsize (MB) : 2048
==> default: --- Guest OS type : centos-64
==> default: --- Virtual Network : ["NOC"]
==> default: --- Nic Type : e1000
==> default: --- Resource Pool :
VMware ovftool 4.2.0 (build-5965791)
Opening VMX source: /root/.vagrant.d/boxes/generic-VAGRANTSLASH-centos7/1.3.40/vmware_desktop/ZZZZ_V-root-TEST_VM.vmx
Opening VI target: vi://[email protected]:443/
Error: Invalid target datastore specified (SyntaxError: invalid syntax): Possible completions:
vms-noc-01-local-storage-1
Completed with errors
There was an OVF Tool error.

esxi.vm_disk_store = "vms-noc-01-local-storage-1"

Is this a bug or am I missing something?

getaddrinfo: nodename nor servname provided

Hi there,

Thanks so much for working on this plugin, it's really excellent work and very considerate of you to continue updating it.

I'm attempting to bring up an Ubuntu box and the transfer works successfully, but after Waiting for state "running" I get a crash:

/Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/read_state.rb:24:in `getaddrinfo': getaddrinfo: nodename nor servname provided, or not known (SocketError)
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/read_state.rb:24:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/read_ssh_info.rb:16:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:227:in `action_raw'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:202:in `block in action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:600:in `lock'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `action'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/provider.rb:24:in `state'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:514:in `state'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/wait_for_state.rb:27:in `block in call'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/timeout.rb:93:in `block in timeout'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/timeout.rb:33:in `block in catch'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/timeout.rb:33:in `catch'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/timeout.rb:33:in `catch'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/timeout.rb:108:in `timeout'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/wait_for_state.rb:26:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/call.rb:43:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/boot.rb:16:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/read_state.rb:29:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/createvm.rb:17:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/read_state.rb:29:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/clong/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.0.2/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:227:in `action_raw'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:202:in `block in action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:631:in `lock'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
	from /opt/vagrant/embedded/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

Here's my sample Vagrantfile:

Vagrant.configure("2") do |config|

  config.vm.define "logger" do |cfg|
    cfg.vm.box = "bento/ubuntu-16.04"
    cfg.vm.hostname = "logger"
    config.vm.provision :shell, path: "bootstrap.sh"
    cfg.vm.network :private_network, ip: "192.168.38.5", gateway: "192.168.38.1", dns: "8.8.8.8"

    cfg.vm.provider "vmware_fusion" do |v, override|
      v.memory = 2048
      v.cpus = 1
      v.gui = true
    end

    cfg.vm.provider "vmware_esxi" do |esxi, override|
      esxi.guest_numvcpus = '2'
      esxi.guest_memsize = '2048'
      esxi.esxi_hostname = '192.168.3.105'
      esxi.esxi_password = "env:esxi_password"
      esxi.esxi_virtual_network = ['NAT Network','VM Network 3']
      esxi.guest_name = 'logger'
    end

    cfg.vm.provider "virtualbox" do |vb, override|
      vb.gui = true
      vb.customize ["modifyvm", :id, "--memory", 2048]
      vb.customize ["modifyvm", :id, "--cpus", 1]
      vb.customize ["modifyvm", :id, "--vram", "32"]
      vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
      vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
    end
  end
end

OVF Tool Error

Hello. When trying to deploy some ready-made vagrant boxes, the following error is appearing:

ERROR vagrant: /root/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.0/lib/vagrant-vmware-esxi/action/createvm.rb:516:in createvm' /root/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.0/lib/vagrant-vmware-esxi/action/createvm.rb:16:in call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in call' /root/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in call' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/handle_box.rb:56:in call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in call' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/config_validate.rb:25:in call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in call' /root/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.0/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in call' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builder.rb:116:in call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in block in run' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/util/busy.rb:19:in busy'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in run' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:227:in action_raw'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:202:in block in action' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/environment.rb:592:in lock'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:188:in call' /opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:188:in action'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
INFO interface: error: There was an OVF Tool error.

My setup
Vagrant 2.0.3 install on Debian 8, 64 bits (3.16.0-5-amd64)
Plugin vagrant-vmware-esxi
VMware ovftool 4.3.0 (build-7948156)

ESXi host:

6.0.0 (Build 2809209)
no resource_pool

Wrong URL to the template VM

I was following this page to run clones https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm

Clone_from_vm test

Vagrant.configure("2") do |config|
config.vm.box = 'esxi_clone/dummy'

config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)
config.vm.synced_folder('.', '/Vagrantfiles', type: 'rsync', disabled: true)

config.vm.provider :vmware_esxi do |esxi|
esxi.esxi_hostname = "XXX.XX.XX.XXX"
esxi.esxi_username = "XXXXXX"
esxi.esxi_password = 'XXXXXXXX'
esxi.clone_from_vm = 'Templates/win2012R2_template'
esxi.esxi_virtual_network = ["VM Network"]
esxi.esxi_resource_pool = "/"
esxi.local_allow_overwrite = 'True'
end
end

I get Error: Locator does not refer to an object.

And it is missing "/" and it is path value does not look correct: "ha-datacenter/host/HOSTNAME./Resources/"
I tried to change these values by providing full path to VM without luck:
esxi.clone_from_vm
esxi.esxi_resource_pool

Actual where the VM is stored is /vmfs/volumes/datastore1/win2012R2

vagrant --version: 2.1.4
vagrant-vmware-esxi (2.4.1, global)

Please help.
Thanks,
vagrant_error

Vaidas

Feature Request: SSH reconnect after building VM

If building an ESXi image over a relatively slow network connection (e.g. a VPN), this can take a while.

After creating the VM, createvm.rb uses the existing SSH connection to execute "vim-cmd vmsvc/getallvm" to get the VM ID - however, I have found this to fail when the VM build has taken a long time, as the existing SSH connection has been closed.

If I simply end the SSH Session and start a new one to execute the final command, then it works - which seems to be more robust.

OVF Tool error: Invalid target datastore specified (ESXi)

Hi!

I am trying to bring up the default vm with vagrant on my ESXi 6.5 (update 1) server, but it always fails with the error above:

[test@test ~]$ vagrant up
Bringing machine 'default' up with 'vmware_esxi' provider...
==> default: Virtual Machine will be built.
==> default: --- WARNING : unraid_ssd not found, using ESXi.
==> default: --- ESXi host : *****
==> default: --- VM Name : V-test-test-test
==> default: --- CPUS : 1
==> default: --- Memsize (MB) : 512
==> default: --- Guest OS type : ubuntu-64
==> default: --- Disk Store : ESXi
==> default: --- NetworkName : "VM Network"
==> default: --- Resource Pool :
VMware ovftool 4.2.0 (build-5965791)
Opening VMX source: /home/test/.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/vmware_fusion/ZZZZ_V-test-test-test.vmx
Opening VI target: vi://[email protected]:443/
Error: Invalid target datastore specified (ESXi): Possible completions:
ESXi USB
unraid_ssd
Completed with errors
There was an OVF Tool error.

[test@test ~]$

The available datastores are listed correctly after the error.
It doesn't matter which if I select one of the two available datastores or just leave it at default in the Vagrantfile.

Found this forum topic about a similar problem: https://communities.vmware.com/thread/428328

Thanks

Cannot mount NFS synced folders

I cannot seem to get NFS synced folders working. I get the following error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 127.0.1.1:/home/axel/.homestead /vagrant

Stdout from the command:

Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported

I'm guessing the problem is that instead of the 127.0.1.1 IP address it should be my network IP address. I have also tried doing the following but without luck:

config.vm.synced_folder('192.168.20.14:/home/axel/.homestead', '/vagrant', type: 'nfs')

What am I missing or is it not doable?

Both the ESXi server and my computer are on the same network.

I'm trying to get Laravel Homestead to work through a virtual machine hosted on ESXi server instead of locally.

Guest-specific operations were attempted on a machine that is not ready for guest communication: Error Observed

Hi Jonathan,

I observed the issue when bringing up VMs using the plugin by triggering a script.

RUBY_PLATFORM: x86_64-linux
==> test-esx-vm: --- ESXi version    : VMware ESXi 6.5.0 build-4887370
Bringing machine 'test-esx-vm' up with 'vmware_esxi' provider...
==> test-esx-vm: Virtual Machine will be built.
==> test-esx-vm: --- Avail DS vols   : ["datastore1"]
==> test-esx-vm: --- WARNING         : esxi_disk_store not set, using "--- Least Used ---"
==> test-esx-vm: --- Avail Networks  : ["VM Network", "Management Network", "", "internal"]
==> test-esx-vm: --- Network[0]      : VM Network
==> test-esx-vm: ---   --- ESXi Summary ---
==> test-esx-vm: --- ESXi host       : 10.xx.xx.xx
==> test-esx-vm: --- Virtual Network : ["VM Network"]
==> test-esx-vm: --- Disk Store      : datastore1
==> test-esx-vm: --- Resource Pool   : /
==> test-esx-vm: ---  --- Guest Summary ---
==> test-esx-vm: --- VM Name         : test-esx-vm
==> test-esx-vm: --- Box             : bento/ubuntu-16.04
==> test-esx-vm: --- Box Ver         : 201801.02.0
==> test-esx-vm: --- Memsize (MB)    : 6000
==> test-esx-vm: --- CPUS            : 2
==> test-esx-vm: --- Guest OS type   : ubuntu-64
==> test-esx-vm: ---   --- Guest Build ---
VMware ovftool 4.2.0 (build-5965791)
ovftool command: ovftool --noSSLVerify   --net:"net0=VM Network" -dm=thin  -ds="datastore1" --name="test-esx-vm" "/home/hostname/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-esx-vm.vmx" vi://root:******@10.xx.xx.xx/
Opening VMX source: /home/sdptest/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-esx-vm.vmx
Opening VI target: vi://[email protected]:443/
Deploying to VI: vi://[email protected]:443/
Transfer Completed
Completed successfully
==> test-esx-vm: --- Keeping file    : /home/hostname/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-esx-vm.vmx
==> test-esx-vm: --- VMID            : 327
==> test-esx-vm: --- Custom vmx      : Append vhv.enable = "TRUE"
==> test-esx-vm: --- VM has been Powered On...
==> test-esx-vm: --- Waiting for state "running"
==> test-esx-vm: --- Success, state is now "running"
num adapters: 1,  vm.network.count: 0
    test-esx-vm:
    test-esx-vm: Vagrant insecure key detected. Vagrant will automatically replace
    test-esx-vm: this with a newly generated keypair for better security.
    test-esx-vm:
    test-esx-vm: Inserting generated public key within guest...
    test-esx-vm: Removing insecure key from the guest if it's present...
    test-esx-vm: Key inserted! Disconnecting and reconnecting using new SSH key...
==> test-esx-vm: Rsyncing folder: /home/hostname => /vagrant
==> test-esx-vm: Machine not provisioned because `--no-provision` is specified.

RUBY_PLATFORM: x86_64-linux
==> test-esx-vm: --- ESXi version    : VMware ESXi 6.5.0 build-4887370
==> test-esx-vm: powered off
==> test-esx-vm: Virtual Machine is already built.
==> test-esx-vm: --- VM has been Powered On...
num adapters: 1,  vm.network.count: 0
**Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.**

Script does the following:

vagrant up --provider=vmware_esxi --no-provision
#some operation to get the IP of the VM (vagrant ssh-config and obtain IP)
sleep 10
vagrant reload --provision

Vagrantfile:

#TODO: Configure private networks and assign static ip
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
  config.vm.define test-esx-vm do |x|
    x.vm.box = "bento/ubuntu-16.04"
    x.vm.provider :vmware_esxi do |v|
      v.esxi_hostname = 10.xx.xx.xx
      v.esxi_username = "root"
      v.esxi_password = "password"
      v.guest_custom_vmx_settings = [['vhv.enable', 'TRUE']]
      v.guest_name = test-esx-vm
      v.guest_memsize = 6000
      v.guest_numvcpus = 2
      v.esxi_virtual_network = ["VM Network"]
      v.debug = "true"
    end
    x.vm.provision :shell do |s|
       s.path = /home/script.sh
    end
  end
end

Version


vagrant-vmware-esxi (2.0.6)

Machine does not start during multiple deployment

So, one machine does not start during multiple(2) deployment.

Vagrant version:

Installed Version: 2.1.1
Latest Version: 2.1.1
You're running an up-to-date version of Vagrant!

lsb_resease

Description:    Linux Mint 18 Sarah

Vagrantfile:

nodes = [
  { hostname: 'VM-multi1', box: 'opentable/win-2012r2-standard-amd64-nocm' },
  { hostname: 'VM-multi2', box: 'opentable/win-2012r2-standard-amd64-nocm' }
]

Vagrant.configure("2") do |config|
  nodes.each do |node|
    config.vm.define node[:hostname] do |node_config|
      node_config.vm.hostname = node[:hostname]
      node_config.vm.box = node[:box]
      node_config.vm.communicator = "winrm"
      node_config.winrm.username = "vagrant"
      node_config.winrm.password = "vagrant"
      node_config.vm.provision "shell", inline: "mkdir c:\\test"
      node_config.vm.provision :shell, :path => "./provision.ps1"
    end
  end

  config.vm.provider :vmware_esxi do |esxi|
    esxi.esxi_hostname = 'ip address'
    esxi.esxi_username = 'username'
    esxi.esxi_password = 'qwerty'
    esxi.debug = 'true'
  end
end

Error happens here:

==> VM-multi1: --- VM has been Powered On...
==> VM-multi2: --- VM has been Powered On...
==> VM-multi1: --- Waiting for state "running"
==> VM-multi2: --- Waiting for state "running"
==> VM-multi1: --- Success, state is now "running"
num adapters: 1,  vm.network.count: 0
==> VM-multi2: --- Success, state is now "running"
num adapters: 1,  vm.network.count: 0
==> VM-multi1: Setting hostname...
==> VM-multi2: Setting hostname...
**==> VM-multi2: An error occurred. The error will be shown after all tasks complete.**
==> VM-multi1: Running provisioner: shell...

Error text:

An unexpected error occurred when executing the action on the
'VM-multi2' machine. Please report this as a bug:

Bad HTTP response returned from server. Body(if present): (500).

/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/http/response_handler.rb:90:in `raise_transport_error'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/http/response_handler.rb:54:in `raise_if_error'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/http/response_handler.rb:36:in `parse_to_xml'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/http/transport.rb:186:in `send_request'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/shells/power_shell.rb:44:in `close_shell'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/shells/base.rb:90:in `close'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/connection.rb:46:in `ensure in shell'
/opt/vagrant/embedded/gems/2.1.1/gems/winrm-2.2.3/lib/winrm/connection.rb:46:in `shell'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/plugins/communicators/winrm/shell.rb:58:in `powershell'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/plugins/communicators/winrm/communicator.rb:148:in `execute'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/plugins/guests/windows/cap/reboot.rb:12:in `wait_for_reboot'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/capability_host.rb:111:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/capability_host.rb:111:in `capability'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/guest.rb:43:in `capability'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/plugins/guests/windows/cap/change_host_name.rb:32:in `change_host_name_and_wait'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/plugins/guests/windows/cap/change_host_name.rb:7:in `change_host_name'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/capability_host.rb:111:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/capability_host.rb:111:in `capability'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/guest.rb:43:in `capability'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/set_hostname.rb:21:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/synced_folders.rb:87:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/plugins/synced_folders/nfs/action_cleanup.rb:25:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/provision.rb:80:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builder.rb:116:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/runner.rb:66:in `block in run'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/util/busy.rb:19:in `busy'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/runner.rb:66:in `run'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/call.rb:53:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/set_network_ip.rb:20:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builder.rb:116:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/runner.rb:66:in `block in run'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/util/busy.rb:19:in `busy'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/runner.rb:66:in `run'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/call.rb:53:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/boot.rb:16:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/createvm.rb:19:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/home/nekto/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/builder.rb:116:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/runner.rb:66:in `block in run'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/util/busy.rb:19:in `busy'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/action/runner.rb:66:in `run'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/machine.rb:239:in `action_raw'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/machine.rb:208:in `block in action'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/environment.rb:598:in `lock'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/machine.rb:194:in `call'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/machine.rb:194:in `action'
/opt/vagrant/embedded/gems/2.1.1/gems/vagrant-2.1.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
/opt/vagrant/embedded/gems/2.1.1/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

VM gets disconnected on creating bridge interface in provisioning script

Hi Jonathan,

I run a provisioning script post bringing up the VM using the plugin.
The script creates a bridge interface for the eth0 and migrates its IP to eth0_br, when this happens the provisioning script hangs and doesnt proceed further

I wanted to know if the plugin supports this behavior or whether plugin loses connectivity when IP is migrated. Looking for an idea.

What is happening:

Interface before running the script:

eth0      Link encap:Ethernet  HWaddr 00:0c:29:8d:70:50
          inet addr:10.xx.xx.xx  Bcast:10.73.41.255  Mask:255.255.254.0
          inet6 addr: fe80::20c:29ff:fe8d:7050/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:769139 errors:0 dropped:0 overruns:0 frame:0
          TX packets:328946 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1066226238 (1.0 GB)  TX bytes:23426075 (23.4 MB)

Interface post the script: (hangs after creating the bridge)

eth0      Link encap:Ethernet  HWaddr 00:0c:29:8d:70:50
          inet6 addr: fe80::20c:29ff:fe8d:7050/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:769139 errors:0 dropped:0 overruns:0 frame:0
          TX packets:328946 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1066226238 (1.0 GB)  TX bytes:23426075 (23.4 MB)

eth0_br   Link encap:Ethernet  HWaddr 52:54:00:90:85:35
          inet addr:10.xx.xx.xx Bcast:10.73.41.255  Mask:255.255.254.0
          inet6 addr: fe80::5054:ff:fe90:8535/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4875 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:229964 (229.9 KB)  TX bytes:9218 (9.2 KB)

Feature Request - Make it use linked clones rather than creating copies

It would be really useful, and significantly faster, if instead of it creating a clone of the disk it created a linked clone so each new machine only created a differencing disk. Most of what I want to do uses the same base image. But thanks for what you've done so far, it's really useful

set_esxi_password: undefined method `gsub' for nil:NilClass (NoMethodError)

Vagrant 2.0.2

vagrant up ubuntu_e  --provider=vmware_esxi

/home/as/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.1/lib/vagrant-vmware-esxi/action/esxi_password.rb:110:in `set_esxi_password': undefined method `gsub' for nil:NilClass (NoMethodError)
	from /home/as/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.1/lib/vagrant-vmware-esxi/action/esxi_password.rb:17:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/action/runner.rb:66:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/action/runner.rb:66:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:227:in `action_raw'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:202:in `block in action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/environment.rb:592:in `lock'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:188:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:188:in `action'
	from /home/as/.vagrant.d/gems/2.4.3/gems/vagrant-vmware-esxi-2.2.1/lib/vagrant-vmware-esxi/provider.rb:24:in `state'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:514:in `state'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:145:in `initialize'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/vagrantfile.rb:79:in `new'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/vagrantfile.rb:79:in `machine'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/environment.rb:694:in `machine'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/plugin/v2/command.rb:180:in `block in with_target_vms'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/plugin/v2/command.rb:204:in `block in with_target_vms'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/plugin/v2/command.rb:186:in `each'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/plugin/v2/command.rb:186:in `with_target_vms'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/plugins/commands/up/command.rb:87:in `execute'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/cli.rb:46:in `execute'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/lib/vagrant/environment.rb:269:in `cli'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.2/bin/vagrant:151:in `<main>'

License?

I would like to try out your esxi vagrant plugin, but having a GPL licensed vagrant plugin is a no-go, because it would mean that any Vagrantfile would need to be GPL too. Why didn't you use MIT (like Vagrant itself) or LGPL?

Assign static IP

Hi,

How one can assign a static IP in a multi interface VM.

Regards

Support for Windows VMs?

Hello,

While using this as a provider for a Windows VM, I get the following:

==> dc: Pruning invalid NFS exports. Administrator privileges will be required...
==> dc: Exporting NFS shared folders...
==> dc: Preparing to edit /etc/exports. Administrator privileges will be required...
==> dc: Mounting NFS shared folders...
Vagrant attempted to execute the capability 'mount_nfs_folder'
on the detect guest OS 'windows', but the guest doesn't
support that capability. This capability is required for your
configuration of Vagrant. Please either reconfigure Vagrant to
avoid this capability or fix the issue by creating the capability.

Is it possible to launch a Windows VM and sync folders with anything other than NFS at this time?

Exit code is 0 on failure

vagrant up failed with the timeout error:

Failed, timeout waiting for "running"

But, surprisingly, the exit code is 0 when this happen. Shouldn't it be 1 (or something else)?

gracefull shutdown and reload

Within the same Vagrantfile, I'm looking to run one set of shell commands, reboot the vm then run a second set of shell commands.
Example:

config.vm.provision "shell", inline: <<- SHELL 
  echo "first block of commands"
  reboot
SHELL

config.vm.provision :reload
config.vm.provision "shell", inline: <<- SHELL 
  echo "second block of commands"
SHELL

However, I get the following errors (only first set of commands ran. "shutdown -r" also did not work):

==> default: Running provisioner: reload... 
==> default --Starting graceful shutdown...
There was an error talking to ESXi. 
  Unable to shutdown the VM: 
    (vmodl.fault.SystemError) { 
    faultCause = (vmodl.MethodFault) null,
    reason = "Invalid fault", 
    msg = "Received SOAP response fault from [<cs: p: -------, TCP:localhost:80>]: shutdownGuest
vim.fault.genericVmConfigFault" 

Is the following made to help with graceful shutdown [lib/vagrant-vmware-esxi/action/shutdown.rb]? If so, how can it be used in the Vagrantfile?

VMware ESXi 6.5 guestOS types needs 'Guest'

Your wiki page about "VMware ESXi 6.5 guestOS types" mentioned you removed 'Guest'. There is not a direct (identical) match between guestOS in vmx file and GuestID for a VM.

Failes (windows8Server64):

PS D:\> Get-VM -Name quickTest01 | Set-VM -GuestID windows8Server64

Confirmation
Proceed to configure the following parameters of the virtual machine with name 'quickTest01'?
New GuestId: windows8Server64
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
Set-VM : 18.04.2018 14.10.50    Set-VM          The guest operating system 'windows8Server64' is not supported on the host.
At line:1 char:35
+ ... me quickTest01 | Set-VM -GuestID windows8Server64
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-VM], InvalidArgument
    + FullyQualifiedErrorId : Client20_VMServiceImpl_TryValidateGuestId_UnsupportedGuestId,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM

Works (windows8Server64Guest):

PS D:\> Get-VM -Name quickTest01 | Set-VM -GuestID windows8Server64Guest

Confirmation
Proceed to configure the following parameters of the virtual machine with name 'quickTest01'?
New GuestId: windows8Server64Guest
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
quickTest01   PoweredOff 1        1,000

undefined method `fire_triggers' for nil:NilClass (NoMethodError)

Hi there, I'm seeing this issue on both Mac OSX & CentOS. Clean install of Vagrant on both. Tried a few permutations on the Vagrantfile including the default single VM one from the examples.

/opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:164:in `action': undefined method `fire_triggers' for nil:NilClass (NoMethodError)
	from /home/user01/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.2.1/lib/vagrant-vmware-esxi/provider.rb:24:in `state'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:521:in `state'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:145:in `initialize'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/vagrantfile.rb:79:in `new'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/vagrantfile.rb:79:in `machine'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/environment.rb:700:in `machine'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:180:in `block in with_target_vms'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:204:in `block in with_target_vms'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:186:in `each'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:186:in `with_target_vms'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/plugins/commands/up/command.rb:87:in `execute'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/cli.rb:54:in `execute'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/environment.rb:275:in `cli'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/bin/vagrant:156:in `<main>'
[user01@deploy01 ~]$ vagrant --version
Vagrant 2.1.0
[user01@deploy01 ~]$ ovftool --version
VMware ovftool 4.3.0 (build-7948156)

network.service failed

When creating a VM of box type generic/centos7 I'm getting following error message:

Bringing machine 'centos1' up with 'vmware_esxi' provider...
==> centos1: Box 'generic/centos7' could not be found. Attempting to find and install...
    centos1: Box Provider: vmware_esxi, vmware, vmware_desktop, vmware_fusion, vmware_workstation
    centos1: Box Version: >= 0
==> centos1: Loading metadata for box 'generic/centos7'
    centos1: URL: https://vagrantcloud.com/generic/centos7
==> centos1: Adding box 'generic/centos7' (v1.5.0) for provider: vmware_desktop
    centos1: Downloading: https://vagrantcloud.com/generic/boxes/centos7/versions/1.5.0/providers/vmware_desktop.box
==> centos1: Successfully added box 'generic/centos7' (v1.5.0) for 'vmware_desktop'!
==> centos1: Virtual Machine will be built.
VMware ovftool 4.3.0 (build-7948156)
==> centos1: --- WARNING         : esxi_virtual_network[0] not set, using VM Network
==> centos1: ---   --- ESXi Summary ---
==> centos1: --- ESXi host       : 70.0.0.67
==> centos1: --- Virtual Network : ["VM Network"]
==> centos1: --- Disk Store      : HDD
==> centos1: --- Resource Pool   : /
==> centos1: ---  --- Guest Summary ---
==> centos1: --- VM Name         : centos1
==> centos1: --- Box             : generic/centos7
==> centos1: --- Box Ver         : 1.5.0
==> centos1: --- Memsize (MB)    : 4096
==> centos1: --- CPUS            : 2
==> centos1: --- Boot Disk Size  : 50GB
==> centos1: --- Storage (GB)    : [100]
==> centos1: --- Guest OS type   : centos-64
==> centos1: ---   --- Guest Build ---
Opening VMX source: /home/as/.vagrant.d/boxes/generic-VAGRANTSLASH-centos7/1.5.0/vmware_desktop/ZZZZ_centos1.vmx
Opening VI target: vi://[email protected]:443/
Deploying to VI: vi://[email protected]:443/
Transfer Completed                    
Completed successfully
==> centos1: --- VMID            : 18
==> centos1: --- Extend Boot dsk : 50GB
==> centos1: --- Creating Storage: disk_0.vmdk (100GB)
==> centos1: --- VM has been Powered On...
==> centos1: --- Waiting for state "running"
==> centos1: --- Success, state is now "running"
==> centos1: Setting hostname...
    centos1: 
    centos1: Vagrant insecure key detected. Vagrant will automatically replace
    centos1: this with a newly generated keypair for better security.
    centos1: 
    centos1: Inserting generated public key within guest...
    centos1: Removing insecure key from the guest if it's present...
    centos1: Key inserted! Disconnecting and reconnecting using new SSH key...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Update sysconfig
sed -i 's/\(HOSTNAME=\).*/\1centos1/' /etc/sysconfig/network

# Update DNS
sed -i 's/\(DHCP_HOSTNAME=\).*/\1"centos1"/' /etc/sysconfig/network-scripts/ifcfg-*

# Set the hostname - use hostnamectl if available
echo 'centos1' > /etc/hostname
if command -v hostnamectl; then
  hostnamectl set-hostname --static 'centos1'
  hostnamectl set-hostname --transient 'centos1'
else
  hostname -F /etc/hostname
fi

# Prepend ourselves to /etc/hosts
grep -w 'centos1' /etc/hosts || {
  sed -i'' '1i 127.0.0.1\tcentos1\tcentos1' /etc/hosts
}

# Restart network
service network restart


Stdout from the command:

/bin/hostnamectl
Restarting network (via systemctl):  [FAILED]


Stderr from the command:

Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

Investigating further

journalctl -eu network

May 09 18:49:43 bazinga.localdomain network[865]: Bringing up loopback interface:  [  OK  ]
May 09 18:49:44 bazinga.localdomain network[865]: Bringing up interface ens33:  Error: Connection activation failed: No suitable dev
May 09 18:49:44 bazinga.localdomain network[865]: [FAILED]
May 09 18:49:44 bazinga.localdomain systemd[1]: network.service: control process exited, code=exited status=1
May 09 18:49:44 bazinga.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
May 09 18:49:44 bazinga.localdomain systemd[1]: Unit network.service entered failed state.
May 09 18:49:44 bazinga.localdomain systemd[1]: network.service failed.

Looking at the VM there is no ens33 interface but rather ens32 interface:

[root@centos1 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:d2:89:48 brd ff:ff:ff:ff:ff:ff
    inet 70.0.178.114/16 brd 70.0.255.255 scope global dynamic ens32
       valid_lft 172158sec preferred_lft 172158sec

There is a relevant Vagrant issue concerning fusion provider:
hashicorp/vagrant#7533

They have a workaround where you can specify different PCI slot number, as such:

  config.vm.provider 'vmware_fusion' do |vf|
     vf.vmx['ethernet0.pcislotnumber'] = '33'
  end

I was able to do a similar workaround in your provider

    dom.vm.provider :vmware_esxi do |v|
        v.guest_custom_vmx_settings = [['ethernet0.pcislotnumber','33']]
    end

I was wondering if there was a way for a more permanent fix.

Wrong password used when creating Ansible inventory for hosts provisioned on different ESXi servers with different passwords

Vagrant Version: 2.0.1
Plugin Version: 2.2.1beta
Client O/S: Mac OSX 10.12.6

In my Vagrant file, I have some hosts that are configured to use one ESX1 server (server1), and some hosts that are configured to use another ESXi server (server2).

When the Ansible provisioner runs, I get an authentication error:

/opt/vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh.rb:250:in `start': Authentication failed for user [email protected] (Net::SSH::AuthenticationFailed)
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.2.1beta/lib/vagrant-vmware-esxi/action/read_state.rb:79:in `read_state'
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.2.1beta/lib/vagrant-vmware-esxi/action/read_state.rb:17:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.2.1beta/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'

I added some debugging information and it looks like the issue is that there is a single global password stored in $esxi_password.

This passwords for server1 and server2 are different so this is likely why this is failing.

How to deal with ova ?

Hi

My vmware box is based on an ova instead of ovf + vmx etc. Seems that's a problem for your plugin

r.garrigue@AST3169 MINGW64 /d/SOURCES/vagrant/cockpit (master)
$  vagrant up --provider=vmware_esxi

RUBY_PLATFORM: x64-mingw32
Testing esxi connectivity
==> default: --- ESXi version    : VMware ESXi 5.1.0 build-1483097
Bringing machine 'default' up with 'vmware_esxi' provider...
==> default: Box 'company/rhel-6' could not be found. Attempting to find and install...
    default: Box Provider: vmware_esxi, vmware, vmware_desktop, vmware_fusion, vmware_workstation
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'company/rhel-6' (v0) for provider: vmware_esxi, vmware, vmware_desktop, vmware_fusion, vmware_workstation
    default: Downloading: https://nexus.company.loc/content/sites/packer/rhel-6-x86_64.vmware.box
    default:
==> default: Successfully added box 'company/rhel-6' (v0) for 'vmware_desktop'!
RUBY_PLATFORM: x64-mingw32
Testing esxi connectivity
==> default: Virtual Machine will be built.
VMware ovftool 4.1.0 (build-3634792)
There was an error.
  Unable to open C:/Users/r.garrigue/.vagrant.d/boxes/company-VAGRANTSLASH-rhel-6/0/vmware_desktop/*.vmx

r.garrigue@AST3169 MINGW64 /d/SOURCES/vagrant/cockpit (master)
$ ls C:/Users/r.garrigue/.vagrant.d/boxes/company-VAGRANTSLASH-rhel-6/0/vmware_desktop
metadata.json  rhel-6.9-x86_64.ova  Vagrantfile

Is it possible to allow .ova easily in your plugin ?

Best regards,

Unable to do a passwordless ssh to the remote esxi server

Hi,

I am trying to do a passwordless ssh to the esxi from my host machine but I am always prompted for the password even though it has been mentioned in the Vagrantfile.

plugin version
vagrant-vmware-esxi (1.5.0)

Issue was also seen on 1.4.0

Trail 1: with setting the password

Vagrantfile

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
  config.vm.define test-vm do |x|
    x.vm.box = "bento/ubuntu-16.04"
    x.vm.provider :vmware_esxi do |v|
      v.esxi_hostname = '10.73.40.19'
      v.esxi_username = 'root'
      v.esxi_password = 'secret'   =====> PASSWORD SET
      v.custom_vmx_settings = [['vhv.enable', 'TRUE']]
      v.vmname = test-vm
      v.memsize = 6000
      v.numvcpus = 2
    end
  end
end

Console Logs

username@hostname:~/home/vagrant$ sudo vagrant up
Bringing machine 'test_vm' up with 'vmware_esxi' provider...
==> test-vm: Virtual Machine will be built.
==> test-vm: --- WARNING         : config.virtual_network not set, using VM Network
==> test-vm: ---
==> test-vm: --- ESXi host       : 10.73.40.19
==> test-vm: --- VM Name         : test-vm
==> test-vm: --- Box             : bento/ubuntu-16.04
==> test-vm: --- Box Ver         : 201801.02.0
==> test-vm: --- Disk Store      : datastore1
==> test-vm: --- CPUS            : 2
==> test-vm: --- Memsize (MB)    : 6000
==> test-vm: --- Guest OS type   : ubuntu-64
==> test-vm: --- Virtual Network : ["VM Network"]
==>test-vm: --- Resource Pool   :
VMware ovftool 4.2.0 (build-5965791)
Opening VMX source: /home/username/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-vm.vmx
Enter login information for target vi://10.73.40.19/
Username: root
Password: **********  =====> PASSWORD PROMPT
Opening VI target: vi://[email protected]:443/
Deploying to VI: vi://[email protected]:443/

Trial 2: with password in a file

Vagrantfile:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_agent = true
  config.vm.define test-vm do |x|
    x.vm.box = "bento/ubuntu-16.04"
    x.vm.provider :vmware_esxi do |v|
      v.esxi_hostname = '10.73.40.19'
      v.esxi_username = 'root'
      v.esxi_password = 'file:/tmp/esxi_password'   =====> PASSWORD SET THROUGH FILE
      v.custom_vmx_settings = [['vhv.enable', 'TRUE']]
      v.vmname = test-vm
      v.memsize = 6000
      v.numvcpus = 2
    end
  end
end

username@host-name:~/home/vagrant$ ls -l /tmp/esxi_password
-rw-r--r-- 1 root root 11 Jan 26 10:00 /tmp/esxi_password
username@host-name:~/home/vagrant$ cat /tmp/esxi_password
secret

Console logs:

username@host-name:~/home/vagrant$ sudo vagrant up
Bringing machine 'test-vm' up with 'vmware_esxi' provider...
==> test-vm: Virtual Machine will be built.
==> test-vm: --- WARNING         : config.virtual_network not set, using VM Network
==> test-vm: ---
==> test-vm: --- ESXi host       : 10.73.40.19
==> test-vm: --- VM Name         : test-vm
==> test-vm: --- Box             : bento/ubuntu-16.04
==> test-vm: --- Box Ver         : 201801.02.0
==> test-vm: --- Disk Store      : datastore1
==> test-vm: --- CPUS            : 2
==> test-vm: --- Memsize (MB)    : 6000
==> test-vm: --- Guest OS type   : ubuntu-64
==> test-vm: --- Virtual Network : ["VM Network"]
==> test-vm: --- Resource Pool   :
VMware ovftool 4.2.0 (build-5965791)
Opening VMX source: /home/username/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201801.02.0/vmware_desktop/ZZZZ_test-vm.vmx
Enter login information for target vi://10.73.40.19/
Username: root
Password: **********   =====> PASSWORD PROMPT
Opening VI target: vi://[email protected]:443/
Deploying to VI: vi://[email protected]:443/

Am I missing something or using it the wrong way?
Only after entering the password the deployment starts. Is there way to do a passwordless ssh to the esxi server?

Regards

rsync in sample file

This is a minor issue, but it took me 15 minutes to figure out what is going wrong.

The sample Vagrant file is a bit misleading when it comes to the synced_folder option. The machine is created without a synced folder, as the second line overwrites the first.

  #  Use rsync and NFS synced folders. (or disable them)
  config.vm.synced_folder('.', '/vagrant', type: 'rsync')
  config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)

I would go for

  #  Use rsync and NFS synced folders. (or disable them)
  #config.vm.synced_folder('.', '/vagrant', type: 'rsync')
  config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)

or

  #  Use rsync and NFS synced folders. (or disable them)
  #config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)
  config.vm.synced_folder('.', '/vagrant', type: 'rsync')

This does what I would expected. It rsyncs the local folder to /vagrant.

Assign IP to Management Interface and Username/Password Setting

Hi,

Thanks for this powerful plugin.
But, there are some problems for my usage (my Box is "generic/centos6)":

  1. according to the readme, it seems I cannot assign IP to management interface. For management-wise and automation purpose, I prefer to give a static IP to my provisioned VM. Is there any suggestion to achieve this goal simply via Vagrant?

  2. I try to set username/password to my VM via config.ssh.username and config.ssh.password, but it doesn't work. I cannot login via "vagrant ssh". The error message is as following:
    "==> default: The machine you're attempting to SSH into is configured to use
    ==> default: password-based authentication. Vagrant can't script entering the
    ==> default: password for you. If you're prompted for a password, please enter
    ==> default: the same password you have configured in the Vagrantfile.".

I cannot login via console as well. Do I misconfigure my Vagrantfile?

Thanks in advance for your time, and look forward to your reply.

Ming-Chen

custom_vmx_settings are not being transferred by ovftool to ESXI server

Hi,

I am trying to bring up VMs on my ESXI server (6.5) using the plugin. In the Vagrantfile I have defined some custom_vmx_settings to enable hardware virtualization.

Vagrantfile:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.forward_agent = true
config.vm.define CFG_MASTER_NODE_NAME do |x|
x.vm.box = "bento/ubuntu-16.04"
x.vm.provider :vmware_esxi do |v|
v.esxi_hostname = '10.73.40.19'
v.esxi_username = 'root'
v.esxi_password = 'mypassword'
v.custom_vmx_settings = [['vhv.enable', 'TRUE']] ===> CUSTOM SETTING
v.vmname = 'test_vm'
v.memsize = "6144"
v.numvcpus = "4"
end
x.vm.provision :shell do |s|
s.path = CFG_MASTER_NODE_PROVISION_SCRIPT
s.args = ["-m", CFG_SDP_USER_PASSWD, CFG_SDP_SRC_FROM_BRANCH, CFG_SDP_SRC_FROM_TAG, CFG_SDP_LAN_INTERFACE, CFG_SDP_WAN_INTERFACE, CFG_SDP_OPTIONAL_INSTALL_PARAMS ]
end
end
end

The vmx file that is created on the machine where ovftool is running is as such and includes the custom settings , vhv.enable="TRUE"

The vmx file passed on to ovftool:

.encoding = "UTF-8"
bios.bootorder = "hdd,CDROM"
checkpoint.vmstate = ""
cleanshutdown = "TRUE"
config.version = "8"
cpuid.corespersocket = "1"
displayname = "test_vm"
ehci.pcislotnumber = "-1"
ehci.present = "FALSE"
extendedconfigfile = "ubuntu-16.04-amd64.vmxf"
floppy0.present = "FALSE"
guestos = "ubuntu-64"
gui.fullscreenatpoweron = "FALSE"
gui.viewmodeatpoweron = "windowed"
hgfs.linkrootshare = "TRUE"
hgfs.maprootshare = "TRUE"
ide1:0.clientdevice = "TRUE"
ide1:0.devicetype = "cdrom-raw"
ide1:0.filename = "auto detect"
ide1:0.present = "TRUE"
isolation.tools.hgfs.disable = "FALSE"
memsize = "6000"
migrate.hostlog = "./ubuntu-16.04-amd64-9eff85f8.hlog"
monitor.phys_bits_used = "40"
msg.autoanswer = "true"
numa.autosize.cookie = "10001"
numa.autosize.vcpu.maxpervirtualnode = "1"
numvcpus = "2"
nvram = "ubuntu-16.04-amd64.nvram"
pcibridge0.pcislotnumber = "17"
pcibridge0.present = "TRUE"
pcibridge4.functions = "8"
pcibridge4.pcislotnumber = "21"
pcibridge4.present = "TRUE"
pcibridge4.virtualdev = "pcieRootPort"
pcibridge5.functions = "8"
pcibridge5.pcislotnumber = "22"
pcibridge5.present = "TRUE"
pcibridge5.virtualdev = "pcieRootPort"
pcibridge6.functions = "8"
pcibridge6.pcislotnumber = "23"
pcibridge6.present = "TRUE"
pcibridge6.virtualdev = "pcieRootPort"
pcibridge7.functions = "8"
pcibridge7.pcislotnumber = "24"
pcibridge7.present = "TRUE"
pcibridge7.virtualdev = "pcieRootPort"
powertype.poweroff = "soft"
powertype.poweron = "soft"
powertype.reset = "soft"
powertype.suspend = "soft"
proxyapps.publishtohost = "FALSE"
remotedisplay.vnc.enabled = "FALSE"
remotedisplay.vnc.ip = "127.0.0.1"
remotedisplay.vnc.key = "KyokGBcvGh0mOgsxOzIoJSwpDSYfNxQtDx0tAzYxCwUnNQUILxgtNzsRNyIdKwEUFx4uFD07ORY2ChYlKz0BGz8PJCYqJw4iJS84CjMNOQI5MTAxMj4sEz0/OzAYGhAqGS44Fx4dIg8aFxU4Jh8KKzMvGRotBgcMMhwZLzU3MBE="
remotedisplay.vnc.password = "wajQzFV1"
remotedisplay.vnc.port = "5903"
replay.filename = ""
replay.supported = "FALSE"
scsi0.pcislotnumber = "16"
scsi0.present = "TRUE"
scsi0.virtualdev = "lsilogic"
scsi0:0.filename = "disk.vmdk"
scsi0:0.present = "TRUE"
scsi0:0.redo = ""
softpoweroff = "TRUE"
sound.startconnected = "FALSE"
tools.synctime = "TRUE"
tools.upgrade.policy = "upgradeAtPowerCycle"
usb.pcislotnumber = "-1"
usb.present = "FALSE"
uuid.action = "create"
uuid.bios = "56 4d 41 16 a3 f7 91 52-6b 79 18 92 29 63 11 af"
uuid.location = "56 4d 41 16 a3 f7 91 52-6b 79 18 92 29 63 11 af"
virtualhw.productcompatibility = "hosted"
virtualhw.version = "9"
vmci0.id = "1861462627"
vmci0.pcislotnumber = "35"
vmci0.present = "TRUE"
vmotion.checkpointfbsize = "67108864"
ethernet0.networkName = "net0"
ethernet0.present = "TRUE"
ethernet0.addressType = "generated"
vhv.enable = "TRUE"
. ==> This has the custom settings.

Now when the ovf deploys on the ESXI server and the VM comes up , the vmx file on the server doesnt have this setting.

From the server:

.encoding = "UTF-8"
config.version = "8"
virtualHW.version = "9"
pciBridge0.present = "TRUE"
svga.present = "TRUE"
pciBridge4.present = "TRUE"
pciBridge4.virtualDev = "pcieRootPort"
pciBridge4.functions = "8"
pciBridge5.present = "TRUE"
pciBridge5.virtualDev = "pcieRootPort"
pciBridge5.functions = "8"
pciBridge6.present = "TRUE"
pciBridge6.virtualDev = "pcieRootPort"
pciBridge6.functions = "8"
pciBridge7.present = "TRUE"
pciBridge7.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
vmci0.present = "TRUE"
hpet0.present = "TRUE"
floppy0.present = "FALSE"
numvcpus = "2"
memSize = "6000"
powerType.suspend = "soft"
tools.upgrade.policy = "upgradeAtPowerCycle"
scsi0.virtualDev = "lsilogic"
scsi0.present = "TRUE"
ide1:0.startConnected = "FALSE"
ide1:0.deviceType = "atapi-cdrom"
ide1:0.fileName = "CD/DVD drive 0"
ide1:0.present = "TRUE"
scsi0:0.deviceType = "scsi-hardDisk"
scsi0:0.fileName = "test_vm.vmdk"
scsi0:0.present = "TRUE"
ethernet0.networkName = "VM Network"
ethernet0.addressType = "generated"
ethernet0.present = "TRUE"
displayName = "test_vm"
guestOS = "ubuntu-64"
toolScripts.afterPowerOn = "TRUE"
toolScripts.afterResume = "TRUE"
toolScripts.beforeSuspend = "TRUE"
toolScripts.beforePowerOff = "TRUE"
tools.syncTime = "TRUE"
uuid.bios = "56 4d ab 85 aa 1f 1f 71-f1 50 ae 56 25 12 a6 2b"
uuid.location = "56 4d ab 85 aa 1f 1f 71-f1 50 ae 56 25 12 a6 2b"
vc.uuid = "52 cd c0 d1 46 5e ab 73-87 ff ae 1b f2 e5 aa ad"
nvram = "test_vm.nvram"
virtualhw.productcompatibility = "hosted"
numa.autosize.vcpu.maxPerVirtualNode = "2"
numa.autosize.cookie = "20001"
sched.swap.derivedName = "/vmfs/volumes/59f6e862-9a92cb8a-bc8a-246e96135a98/test_vm/test_vm-8b4a323e.vswp"
migrate.hostlog = "./test_vm-1-8b4a323e.hlog"
scsi0:0.redo = ""
pciBridge0.pciSlotNumber = "17"
pciBridge4.pciSlotNumber = "21"
pciBridge5.pciSlotNumber = "22"
pciBridge6.pciSlotNumber = "23"
pciBridge7.pciSlotNumber = "24"
scsi0.pciSlotNumber = "16"
ethernet0.pciSlotNumber = "32"
vmci0.pciSlotNumber = "33"
ethernet0.generatedAddress = "00:0c:29:12:a6:2b"
ethernet0.generatedAddressOffset = "0"
vmci0.id = "621979179"
monitor.phys_bits_used = "40"
vmotion.checkpointFBSize = "4194304"
cleanShutdown = "FALSE"
softPowerOff = "FALSE"

I am not sure what I could be missing here.All the other configs I have set in the Vagrantfile are visible on the vmx file on the server.
Is this an issue with the config_version hardcoded to 8 , which translates to ESXI 5.1? Could you please help?

Thanks

NFS Synced Folders not mounting

NFS is not working here:

==> default: Installing NFS client...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=4 127.0.1.1:/home/rgl/Projects/vagrant-vmware-esxi/example_box /vagrant

Stdout from the command:



Stderr from the command:

mount.nfs: access denied by server while mounting 127.0.1.1:/home/rgl/Projects/vagrant-vmware-esxi/example_box

My exports file:

# VAGRANT-BEGIN: 1000 21
"/home/rgl/Projects/vagrant-vmware-esxi/example_box" 10.2.0.182(rw,no_subtree_check,all_squash,anonuid=1000,anongid=1000,fsid=2824420103)
# VAGRANT-END: 1000 21

The IP address on the exports file is the correct VM IP, but for some reason, mount is trying to use 127.0.1.1 instead of the host IP address. Do you have any idea why?

If I manually enter the machine and mount with the correct host ip address, it works fine:

mount -o vers=4 10.2.0.1:/home/rgl/Projects/vagrant-vmware-esxi/example_box /vagrant
mount
# 10.2.0.1:/home/rgl/Projects/vagrant-vmware-esxi/example_box on /vagrant type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.2.0.182,local_lock=none,addr=10.2.0.1)

Unable to get list of Disk Stores:

Hello,

I started trying this plugin today and although i could set up everything relatively easily. The creation of a vm came to a sudden halt. I got this error:

==> default: Virtual Machine will be built.
VMware ovftool 4.3.0 (build-7948156)
ERROR warden: Error occurred: There was an error talking to ESXi.

ERROR vagrant: Vagrant experienced an error! Details:
ERROR vagrant: #<VagrantPlugins::ESXi::Errors::ESXiError: There was an error talking to ESXi.
Unable to get list of Disk Stores:>
ERROR vagrant: There was an error talking to ESXi.
Unable to get list of Disk Stores:
ERROR vagrant: /home/username/.vagrant.d/gems/2.4.4/gems/vagrant-vmware-esxi-2.3.1/lib/vagrant-vmware-esxi/action/createvm.rb:150:in `block in createvm'

I attached my VagrantFile & log to provide you with more information.

vagrant.log
Vagrantfile.txt

pushing static IP to VM

HI,

Do you think is possible to push static IP to the VM?
My configs are not taken in consideration :(
config.vm.network "public_network", auto_config: false
config.vm.provision "shell",
run: "always",
inline: <<-SHELL
ifconfig eth0 100.64.4.199 netmask 255.255.255.0 up
route add default gw 100.64.4.240
SHELL

vagrant ssh -c does not work

I was unable to execute a single command using vagrant ssh -c "COMMAND". Pull request with bug fix will follow.

Bug In esxi With ssh connection failure on first attempt, success on second

Due to an esxi bug when AD authentication is enabled, the first ssh authentication attempt always fails, even when the password is correct.

As such, each attempt to connect via 'vagrant [command] --provider=vmware-esxi fails.

I unfortunately cannot disable AD authentication, as it's necessary in my environment. Would it be possible to attempt authentication twice before raising the exception:
INFO interface: Machine: error-exit ["VagrantPlugins::ESXi::Errors::ESXiError", "There was an error talking to ESXi.\n Unable to connect to ESXi host!"]

I realize that this is really an esxi issue, but I'm sure there are others who are in the same situation.

Thanks for your plugin. I think it could make my life a lot easier.

Error: Invalid target disk adapter type: pvscsi

I want to create an own base box for some of my deployments. For that

  1. I manually create a VM on my ESXi host (CentOS 7.5.1804 Minimal)
  2. clone from it using vagrant-vmware-esxi to make it managed by vagrant, apply my modifications using setup scripts and eventually have my BaseBox

Step 1: The manually created box

The options when creating the initial box:

  • Name: CentOSBaseSCSI2
  • Guest OS Family: Linux
  • Guest OS Type: CentOS 7 (64 Bit)
  • HDD 64GB thin provisioned which is attached to the SCSI adapter (the default)
  • Installation ISO image connected to the CD drive

The OS doesn't even have to be installed. The problem below does not depend on that

Step 2: Cloning from this initial box

I use the following vagrant file, which is derived from the example for cloning from an existing VM

Vagrant.configure('2') do |config|

  config.vm.box = 'vmware_esxi/dummy'

  config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)

  config.vm.provider :vmware_esxi do |esxi|

        esxi.esxi_hostname = 'esxi02'
        esxi.esxi_username = 'root'
        esxi.esxi_password = 'xxxxxxxx'

        esxi.clone_from_vm = 'myCentOSBaseSCSI2'
        esxi.esxi_resource_pool = "/"

        esxi.debug = 'true ip vmx' # 'true ip vmx'

  end
end

The Error

and run a vagrant up which results in

RUBY_PLATFORM: x86_64-linux
Testing esxi connectivity
==> default: --- ESXi version    : VMware ESXi 6.7.0 build-8169922
Bringing machine 'default' up with 'vmware_esxi' provider...
==> default: Virtual Machine will be built.
VMware ovftool 4.3.0 (build-7948156)
ovftool command: ovftool --noSSLVerify --overwrite --X:useMacNaming=false --powerOffTarget --noDisks --targetType=vmx --X:logLevel=info --X:logFile=/tmp/d20180619-3507-11ypihh/ovftool.log --acceptAllEulas vi://root:******@esxi02/myCentOSBaseSCSI2 /tmp/d20180619-3507-11ypihh
Opening VI source: vi://[email protected]:443/myCentOSBaseSCSI2
Opening VMX target: /tmp/d20180619-3507-11ypihh
Error: Invalid target disk adapter type: pvscsi
Deleting directory tree below: /tmp/d20180619-3507-11ypihh/myCentOSBaseSCSI2
Completed with errors
#<Thread:0x000056485ac29428@/usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/batch_action.rb:71 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        20: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
        19: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:188:in `action'
        18: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:188:in `call'
        17: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/environment.rb:592:in `lock'
        16: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:202:in `block in action'
        15: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/machine.rb:227:in `action_raw'
        14: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/runner.rb:66:in `run'
        13: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/util/busy.rb:19:in `busy'
        12: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/runner.rb:66:in `block in run'
        11: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/builder.rb:116:in `call'
        10: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
         9: from /home2/scratch/xxxx/.vagrant.d/gems/2.5.1/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'
         8: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
         7: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
         6: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
         5: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
         4: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
         3: from /home2/scratch/xxxx/.vagrant.d/gems/2.5.1/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in `call'
         2: from /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
         1: from /home2/scratch/xxxx/.vagrant.d/gems/2.5.1/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/createvm.rb:18:in `call'
/home2/scratch/xxxx/.vagrant.d/gems/2.5.1/gems/vagrant-vmware-esxi-2.3.0/lib/vagrant-vmware-esxi/action/createvm.rb:112:in `createvm': There was an OVF Tool error. (VagrantPlugins::ESXi::Errors::OVFToolError)
  Unable to access myCentOSBaseSCSI2
There was an OVF Tool error.
  Unable to access myCentOSBaseSCSI2

Tracking down the problem

running the ovftool command manually delivers the failure message from the subject: Error: Invalid target disk adapter type: pvscsi

#$ ovftool --noSSLVerify --overwrite --X:useMacNaming=false --powerOffTarget --noDisks --targetType=vmx --X:logLevel=info --X:logFile=/tmp/d20180619-3507-11ypihh/ovftool.log --acceptAllEulas vi://root:*******@esxi02/myCentOSBaseSCSI2 /tmp/d20180619-3507-11ypihh
Enter login information for source vi://192.168.0.12/
Username: root
Password: ***********
Opening VI source: vi://[email protected]:443/myCentOSBaseSCSI2
Opening VMX target: /tmp/d20180619-3507-11ypihh
Error: Invalid target disk adapter type: pvscsi
Deleting directory tree below: /tmp/d20180619-3507-11ypihh/myCentOSBaseSCSI2
Completed with errors

some more experiments

  • Removing the --targetType=vmx option produces an .ovf package instead of an .vmx. In that case, there are no complaints by the ovftool about the target disk adapter.
  • Using a base box where the OS disk is attached to the sata interface instead of the SCSI adapter works fine

My Conclusion :-)

... it seems to be related to the disk adapters of the VM and the packaging format vmx.

  1. Can somebody confirm this behavior?
  2. Is it an ovftool problem? Searching for the failure message brought up some old and some new reports, but nothing I could work with. It seems to be known but not sufficiently treated by VMWare/ovftool.
  3. Should it be handled in vagrant-vmware-esxi? At least it is the default behavior of the solution, and as such ... some solution is needed. At least some documentation.
  4. I now have a workaround for this problem (connecting the disk to the SATA interface), and just wanted to share it here

VM Clone Fails

Host OS: Mac OSX 10.12.6
Plugin Version: 2.1.0
Vagrant Version: 2.0.1

I'm trying to clone an existing VM. Here's a snippet from my Vagrantfile

    windows_victim.vm.provider :vmware_esxi do |esxi, override|

	#Need this to make SSH work, but for rsync you also need to update ~/.ssh/config
         override.ssh.extra_args = '-oHostKeyAlgorithms=+ssh-dss'
		
    	#  REQUIRED!  ESXi hostname/IP
    	esxi.esxi_hostname = "#{ENV['ESX_SERVER_IP']}"
    	
    	#esxi.esxi_resource_pool = "/"
    	esxi.debug = 'true ip vmx'

    	#  ESXi username
    	esxi.esxi_username = 'root'
    	esxi.esxi_password = 'env:ESX_PASSWORD'
    	esxi.esxi_disk_store = 'volume1'
    
	esxi.guest_name_prefix = 'windows-victim-'	
    	esxi.clone_from_vm = 'windows-victim'
 
  
    end

When I run vagrant up I get the following exception:

/Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.1.0/lib/vagrant-vmware-esxi/action/createvm.rb:90:in `read': no implicit conversion of nil into String (TypeError)
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.1.0/lib/vagrant-vmware-esxi/action/createvm.rb:92:in `createvm'
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.1.0/lib/vagrant-vmware-esxi/action/createvm.rb:16:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.1.0/lib/vagrant-vmware-esxi/action/read_state.rb:64:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /Users/josh.bregman/.vagrant.d/gems/2.4.2/gems/vagrant-vmware-esxi-2.1.0/lib/vagrant-vmware-esxi/action/esxi_password.rb:18:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:227:in `action_raw'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:202:in `block in action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:631:in `lock'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
	from /opt/vagrant/embedded/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

Looks like the issue is that when the OVF tool runs:

Writing VMX file: /var/folders/nx/y_rbqrbn1l13h8ml2kr_hnj0pw01l0/T/d20180413-6349-ft9aqe/windows-victim.vmwarevm/windows-victim.vmx

The name of the file is <vm_name>.vmwarevm/<vm_name>.vmx. The code on line 90 isn't adding the .vmwarevm extension. I'm not sure under what conditions this .vmwarevm gets added, so not sure how to "fix it".

Connect to existing VM in ESXi?

Sorry if my questions sound stupid. I'm new to Vagrant and ESXi.

How can we connect to existing VM in ESXi and control them using this plugin?

Unable to get list of Disk Stores

vagrant version

Installed Version: 2.1.1
Latest Version: 2.1.1
 
You're running an up-to-date version of Vagrant!

lsb_release -a

LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	Fedora
Description:	Fedora release 27 (Twenty Seven)
Release:	27
Codename:	TwentySeven

My Vagrantfile

#
#  Fully documented Vagrantfile available
#  in the wiki:  https://github.com/josenk/vagrant-vmware-esxi/wiki
Vagrant.configure('2') do |config|

  #  Box, Select any box created for VMware that is compatible with
  #    the ovftool.  To get maximum compatibility You should download
  #    and install the latest version of ovftool for your OS.
  #    https://www.vmware.com/support/developer/ovf/
  #
  #    If your box is stuck at 'Powered On', then most likely
  #    the box/vm doesn't have the vmware tools installed.
  #
  # Here are some of the MANY examples....
  config.vm.box = 'centos/7'
  #config.vm.box = 'generic/centos6'
  #config.vm.box = 'generic/fedora27'
  #config.vm.box = 'generic/freebsd11'
  #config.vm.box = 'generic/ubuntu1710'
  #config.vm.box = 'generic/debian9'
  #config.vm.box = 'hashicorp/precise64'
  #config.vm.box = 'steveant/CentOS-7.0-1406-Minimal-x64'
  #config.vm.box = 'geerlingguy/centos7'
  #config.vm.box = 'geerlingguy/ubuntu1604'
  #config.vm.box = 'laravel/homestead'
  #config.vm.box = 'puphpet/debian75-x64'


  #  Use rsync and NFS synced folders. (or use the option to disable them)
  #    https://www.vagrantup.com/docs/synced-folders/
  #config.vm.synced_folder('.', '/vagrant', type: 'rsync')
  config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)

  #  Vagrant can configure additional network interfaces using a static IP or
  #  DHCP. Use public_network or private_network to manually set a static IP and
  #  optionally netmask.  ESXi doesn't use the concept of public or private
  #  networks so both are valid here.  The primary network interface is considered the
  #  "vagrant management" interface and cannot be changed and this plugin
  #  supports 4 NICS, so you can specify 3 entries here!
  #
  #  https://www.vagrantup.com/docs/networking/public_network.html
  #  https://www.vagrantup.com/docs/networking/private_network.html
  #
  #    *** Invalid settings could cause 'vagrant up' to fail ***
  #config.vm.network 'private_network', ip: '192.168.10.170', netmask: '255.255.255.0'
  #config.vm.network 'private_network', ip: '192.168.11.170'
  #config.vm.network 'public_network', ip: '192.168.12.170'

  #
  #  Provider (esxi) settings
  #
  config.vm.provider :vmware_esxi do |esxi|

    #  REQUIRED!  ESXi hostname/IP
    esxi.esxi_hostname = '192.168.1.110'

    #  ESXi username
    esxi.esxi_username = 'root'

    #  IMPORTANT!  Set ESXi password.
    #    1) 'prompt:'
    #    2) 'file:'  or  'file:my_secret_file'
    #    3) 'env:'  or 'env:my_secret_env_var'
    #    4) 'key:'  or  key:~/.ssh/some_ssh_private_key'
    #    5) or esxi.esxi_password = 'my_esxi_password'
    #
    esxi.esxi_password = 'esxi@admin'

    #  SSH port.
    #esxi.esxi_hostport = 22

    #  HIGHLY RECOMMENDED!  ESXi Virtual Network
    #    You should specify an ESXi Virtual Network!  If it's not specified, the
    #    default is to use the first found.  You can specify up to 4 virtual
    #    networks using an array format.
    #esxi.esxi_virtual_network = ['VM Network','VM Network2','VM Network3','VM Network4']

    #  OPTIONAL.  Specify a Disk Store
    esxi.esxi_disk_store = 'DS-1'

    #  OPTIONAL.  Resource Pool
    #     Vagrant will NOT create a Resource pool it for you.
    #esxi.esxi_resource_pool = '/Vagrant'

    #  Optional. Specify a VM to clone instead of uploading a box.
    #    Vagrant can use any stopped VM as the source 'box'.   The VM must be
    #    registered, stopped and must have the vagrant insecure ssh key installed.
    #    If the VM is stored in a resource pool, it must be specified.
    #    See wiki: https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm
    #esxi.clone_from_vm = 'resource_pool/source_vm'

    #  OPTIONAL.  Guest VM name to use.
    #    The Default will be automatically generated.
    esxi.guest_name = 'IN01-V-Cent7'

    #  OPTIONAL.  When automatically naming VMs, use this prifix.
    #esxi.guest_name_prefix = 'V-'


    #  OPTIONAL.  Set the guest username login.  The default is 'vagrant'.
    esxi.guest_username = 'dragon'

    #  OPTIONAL.  Memory size override
    esxi.guest_memsize = '4096'

    #  OPTIONAL.  Virtual CPUs override
    esxi.guest_numvcpus = '2'

    #  OPTIONAL & RISKY.  Specify up to 4 MAC addresses
    #    The default is ovftool to automatically generate a MAC address.
    #    You can specify an array of MAC addresses using upper or lower case,
    #    separated by colons ':'.
    #esxi.guest_mac_address = ['00:50:56:aa:bb:cc', '00:50:56:01:01:01','00:50:56:02:02:02','00:50:56:BE:AF:01' ]

    #   OPTIONAL & RISKY.  Specify a guest_nic_type
    #     The validated list of guest_nic_types are 'e1000', 'e1000e', 'vmxnet',
    #     'vmxnet2', 'vmxnet3', 'Vlance', and 'Flexible'.
    esxi.guest_nic_type = 'vmxnet3'

    #  OPTIONAL. Specify a disk type.
    #    If unspecified, it will be set to 'thin'.  Otherwise, you can set to
    #    'thin', 'thick', or 'eagerzeroedthick'
    esxi.guest_disk_type = 'thin'

    #  OPTIONAL. Boot disk size.
    #    If unspecified, the boot disk size will be the same as the original
    #    box.  You can specify a larger boot disk size in GB.  The extra disk space
    #    will NOT automatically be available to your OS.  You will need to
    #    create or modify partitions, LVM and/or filesystems.
    esxi.guest_boot_disk_size = 40

    #  OPTIONAL.  Create additional storage for guests.
    #    You can specify an array of up to 13 virtual disk sizes (in GB) that you
    #    would like the provider to create once the guest has been created.
    #esxi.guest_storage = [10,20]

    #  OPTIONAL. specify snapshot options.
    #esxi.guest_snapshot_includememory = 'true'
    #esxi.guest_snapshot_quiesced = 'true'

    #  RISKY. guest_guestos
    #    https://github.com/josenk/vagrant-vmware-esxi/ESXi_guest_guestos_types.md
    #esxi.guest_guestos = 'centos-64'

    #  OPTIONAL. guest_virtualhw_version
    #    ESXi 6.5 supports these versions. 4,7,8,9,10,11,12 & 13.
    esxi.guest_virtualhw_version = '13'

    #  RISKY. guest_custom_vmx_settings
    #esxi.guest_custom_vmx_settings = [['vhv.enable','TRUE'], ['floppy0.present','TRUE']]

    #  OPTIONAL. local_lax
    #esxi.local_lax = 'true'

    #  OPTIONAL. Guest IP Caching
    #esxi.local_use_ip_cache = 'True'

    #  DANGEROUS!  Allow Overwrite
    #    If unspecified, the default is to produce an error if overwriting
    #    vm's and packages.
    #esxi.local_allow_overwrite = 'True'

    #  Plugin debug output.
    #    Please send any bug reports with debug this output...
    esxi.debug = 'true ip vmx'

  end
end

vagrant up --provider=vmware_esxi


RUBY_PLATFORM: x86_64-linux
Testing esxi connectivity
==> default: --- ESXi version    : VMware ESXi 6.5.0 build-7967591
Bringing machine 'default' up with 'vmware_esxi' provider...
==> default: Virtual Machine will be built.
VMware ovftool 4.3.0 (build-7948156)
==> default: --- Avail DS vols   : []
There was an error talking to ESXi.
  Unable to get list of Disk Stores:

vagrant ssh


RUBY_PLATFORM: x86_64-linux
Testing esxi connectivity
==> default: --- ESXi version    : VMware ESXi 6.5.0 build-7967591
The provider for this Vagrant-managed machine is reporting that it
is not yet ready for SSH. Depending on your provider this can carry
different meanings. Make sure your machine is created and running and
try again. Additionally, check the output of `vagrant status` to verify
that the machine is in the state that you expect. If you continue to
get this error message, please view the documentation for the provider
you're using.

vagrant status

RUBY_PLATFORM: x86_64-linux
Testing esxi connectivity
==> default: --- ESXi version    : VMware ESXi 6.5.0 build-7967591
Current machine states:

default                   not created (vmware_esxi)

No Virtual Machines are created.

I don't know what's wrong here as I can ssh into the host just fine.

Feature Request: Support overrides

Supporting overrides allows people to include multiple different providers in their Vagrantfile. Current output while trying to use this is:

$ vagrant up myhost --provider=vmware_esxi
There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: <provider config: vmware_esxi>
Line number: 89
Message: NameError: undefined local variable or method `override' for main:Object

More info here: https://www.vagrantup.com/docs/providers/configuration.html#overriding-configuration

vagrant up hangs "waiting for state running" when a box without VMWare Tools is Used

If the guest does not have VMWare Tools, the command used in read_ssh_info is unable to get an IP address which causes the state to become stuck at Powered On because read_ssh_info always returns nil which gets checked here.

Manually tested in SSH.

  1. Without VMWare Tools (centos/7)
[root@localhost:~] vim-cmd vmsvc/get.guest 3 | grep ipAddress | head -n 1
   ipAddress = <unset>, 
  1. With VMWare Tools mvermaes/centos7-vmware-tools
[root@localhost:~] vim-cmd vmsvc/get.guest 7 | grep ipAddress | head -n 1
   ipAddress = "192.168.1.43", 

Should "use a box with VMWare Tools" be added to README.md ?

Cannot communicate with guest machine error

I have set up my guest machine in VMware ESXi perfectly. It's working fine. But every now and then I need to re-provision the machine (when I make a change in the Homestead config).

I randomly get the following error.

Bringing machine 'homestead-7' up with 'vmware_esxi' provider...
==> homestead-7: Virtual Machine is already built.
==> homestead-7: The VM is already powered_on.
==> homestead-7: --- Configuring     : 192.168.10.10/255.255.255.0 on Homestead Network
==> homestead-7: --- Configuring     : 172.16.1.200/255.255.0.0 on Local Network
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.

I immediately re-try and sometimes it works and sometimes I get the same error. But if I keep trying it eventually provisions the machine fine.

My setup can be found in Getting the ball rolling for reference.

Additional Hard Drives and Misc Custom Commands

Hi @josenk,

Thanks again for sharing this work, it's really well written and maintained! A couple months back, I started using Vagrant to build prod-like boxes on virtualbox. The virtualbox provider has some #customize method that seems to basically run one of the virtualbox CLIs to perform a task on the VM in the midst of it's creation.

For example, this uses storagectl to attach a stat controller to a virtualbox VM

v.customize ['storagectl', :id, '--name', controller_name, '--add', 'sata', '--portcount', 4] 

...more code available here

Do you have any plans to approach hard drive attachment in this plugin? Have you approached this problem a different way?

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.