vagrant-vsphere
vagrant-vsphere copied to clipboard
Unable to set IP using a customization spec
I get the following when trying to run vagrant:
[root@chef vagrantfile]# vagrant up --provider=vsphere Bringing machine 'default' up with 'vsphere' provider... undefined method `ipAddress=' for #<RbVmomi::VIM::CustomizationUnknownIpGenerator:0x007f6af8f9d520
Here's my Vagrant file, I've verified all the spelling\locations\etc:
[root@chef vagrantfile]# cat Vagrantfile Vagrant.configure("2") do |config| config.vm.box = 'dummy' config.vm.box_url = 'dummy.box'
config.vm.provider :vsphere do |vsphere| vsphere.host = '{vSphere host}' vsphere.data_center_name = 'Datacenter' vsphere.compute_resource_name = '{Cluster}' vsphere.template_name = 'Template 1' vsphere.user = 'Vagrant' vsphere.password = 'xxxxx' vsphere.insecure = 'true' vsphere.data_store_name = 'LUN 11' vsphere.customization_spec_name = 'NE Template' config.vm.network 'private_network', ip: '192.168.1.200' end end
Just so I can stay sane reading it ;) :
Vagrant.configure("2") do |config|
config.vm.box = 'dummy'
config.vm.box_url = 'dummy.box'
config.vm.provider :vsphere do |vsphere|
vsphere.host = '{vSphere host}'
vsphere.data_center_name = 'Datacenter'
vsphere.compute_resource_name = '{Cluster}
vsphere.template_name = 'Template 1'
vsphere.user = 'Vagrant'
vsphere.password = 'xxxxx'
vsphere.insecure = 'true'
vsphere.data_store_name = 'LUN 11'
vsphere.customization_spec_name = 'NE Template'
config.vm.network 'private_network', ip: '192.168.1.200'
end
end
Does your customization spec have a network adapter configured? If not, it won't work.
Also just a tip, you should not change the top level config
object inside of a provider configuration block. If you need to change things on the global config on a per provider basis, you can use the override
:
config.vm.provider :vsphere do |vsphere, override|
override.vm.network 'private_network', ip: '192.168.1.200'
end
I can reproduce your problem when the specification is on DHCP mode and when you also provide an IP address. I'm struggling with the same issue.
Anyone figured out how to setup an IP to a Linux box?
I have the same issue. Any success ?
What happens if you set the config.vm.network object inside the config block, like this:
Vagrant.configure("2") do |config|
config.vm.box = 'dummy'
config.vm.box_url = 'dummy.box'
config.vm.network 'private_network', ip: '192.168.1.200'
config.vm.provider :vsphere do |vsphere|
vsphere.host = '{vSphere host}'
vsphere.data_center_name = 'Datacenter'
vsphere.compute_resource_name = '{Cluster}
vsphere.template_name = 'Template 1'
vsphere.user = 'Vagrant'
vsphere.password = 'xxxxx'
vsphere.insecure = 'true'
vsphere.data_store_name = 'LUN 11'
vsphere.customization_spec_name = 'NE Template'
end
end
@dataplayer I see you point.
vsphere.customization_spec_name = 'NE Template'
Now I understand this section in docs :+1:
The IP address will only be set if a customization spec name is given. The customization spec must have network adapter settings configured. For each private network specified, there needs to be a corresponding network adapter in the customization spec. An error will be thrown if there are more networks than adapters.
Thank you
@dataplayer I added template with two NIC (dhcp and prompt user) and got the same issue:
INFO interface: error: undefined method `ipAddress=' for # <RbVmomi::VIM::CustomizationDhcpIpGenerator:0x0000010136d5d8>
undefined method `ipAddress=' for #<RbVmomi::VIM::CustomizationDhcpIpGenerator:0x0000010136d5d8>
INFO interface: Machine: error-exit ["VagrantPlugins::VSphere::Errors::VSphereError", "undefined method `ipAddress=' for #<RbVmomi::VIM::CustomizationDhcpIpGenerator:0x0000010136d5d8>"]
I was able to get it to work. I set a static IP(just an unused address) in my vsphere customization spec, and then configured the ip in the Vagrant file as documented. After issuing the 'vagrant up' it set the new vm's IP to the one in the config and not the one in the customization spec.
@Spots it's also my solution in this case)
The following is my Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = 'dummy'
config.vm.box_url = 'dummy.box'
config.vm.provider :vsphere do |vsphere, override|
vsphere.host = 'my-vsphere-server-host'
vsphere.name = 'my-hostname'
# vsphere.data_center_name = 'Datacenter'
vsphere.compute_resource_name = 'FM&T Dev Cluster'
vsphere.template_name = 'Templates/t-centos66-vagrant'
vsphere.user = 'username'
vsphere.password = 'password'
vsphere.insecure = 'true'
vsphere.data_store_name = 'intopsz1_vmdk'
vsphere.customization_spec_name = 'centos66'
override.vm.network 'private_network', ip: '10.161.68.209'
end
end
Just wondering what else could be going wrong. Is it absolutely necessary to use a ruby v1.9.3 or higher? I seem to be getting results even with the 1.8.7 enterprise ruby, but setting a static IP is the ever elusive holy grail. Apart from that, it matters not if I use "override.vm.network" or "config.vm.network", or if either of the above is in or out of the config bloc - the ip requested is never set, and there's always the "Vagrant::Errors::SSHNotReady" endless loop at the end (a separate issue I suppose). The IP that IS set however (but which still requires the removal of 70-persistent-net-rules and a reboot to activate properly) is the IP I have in BOTH the customisation specification AND the template I am using. This IP is 10.161.68.199 ... but the REQUIRED IP is that specified in the Vagrantfile, which is 10.161.68.209 as indicated above.
Honestly I wouldn't even mind so much if it was necessary to rm the 70-persistent-net-rules file ONCE with a self-deleting bash script on the initial boot or whatever, as long as the static IP specified in the Vagrantfile got set on eth0.
Can anyone see anything obviously wrong here?
Thanks for any ideas, A./
override.vm.network 'private_network', ip: '10.161.68.209' shouldnt be in there. It should be outside the vagrant block.
config.vm.network 'private_network', ip: '10.161.68.209'
At least that's how mine is working.
Spots, you mean it should be outside the config.vm.provider block, and say "config.vm.network 'private_network', ip: '10.161.68.209' not "override.vm.network 'private_network', ip: '10.161.68.209' ?
Yes, sorry, got in a hurry and forgot to come back.
Here's a config I just used to launch a box:
Vagrant.configure(2) do |config|
config.vm.box = "dummy"
config.vm.box_url = "./dummy.box"
config.vm.network 'private_network', ip: '192.168.123.10'
config.vm.provider :vsphere do |vsphere|
vsphere.name = 'elk-test'
vsphere.customization_spec_name = 'Ubuntu-Static'
vsphere.host = 'myvcenterserver'
vsphere.data_center_name = 'mydatacenter'
vsphere.compute_resource_name = 'mycluster'
vsphere.template_name = 'Ubuntu 14.04 x64 Vagrant with Ansible Template'
vsphere.data_store_name = 'datastore-temp'
vsphere.user = 'user'
vsphere.password = 'password'
end
end
In my customization spec I have it set to a specific address(just something I'm not using NOT the address I want the VM to be). The config.vm.network line will overwrite the ip in the customization spec with the one you set.
Thanks Steve. No cigar yet though, even with your exact vagrantfile as seen in your last post there, but with added "vsphere.insecure = 'true'". I'm thinking it's because my ruby is v1.8.7, so will try a fresh vagrant install tomorrow.
:(
For reference I'm using a Ubuntu 14.04 x64. I installed ruby 1.9.3p551 using rbenv. Vagrant version 1.7.1
Bingo! There was a rather obvious error on my part in the end - which was failing to have a valid vmware-tools on the template. BTW this works with enterprise ruby v.1.8.7 (so having a minimum ruby v.1.9.3 is not a condition after all) and maybe some other, older dependencies I'm not sure, as well as with the most recent recipe described in http://sdorsett.github.io/2014/04/19/vagrant-install/. The OSes we're working with are Centos 6.x.
great job! @Spots this fixed my issues here as well. I created the specs and added that to my vagrant file and it worked like a charm after hours of headache.
i have no idea how to configure the specs could anyone can give me some help thanks
@Y4Rv1K and anyone else hitting this error:
INFO interface: error: undefined method `ipAddress=' for # <RbVmomi::VIM::CustomizationDhcpIpGenerator:0x0000010136d5d8>
undefined method `ipAddress=' for #<RbVmomi::VIM::CustomizationDhcpIpGenerator:0x0000010136d5d8>
INFO interface: Machine: error-exit ["VagrantPlugins::VSphere::Errors::VSphereError", "undefined method `ipAddress=' for #<RbVmomi::VIM::CustomizationDhcpIpGenerator:0x0000010136d5d8>"]
This just means that you have specified more private IP's in your Vagrantfile than the number of existing static IP interfaces in your VSphere spec. Either decrease the number of private IP's, or increase the number of available static interfaces.
has anyone encounter the error "NicSettingMismatch: fault.NicSettingMismatch.summary" could give me some help thank you
@simsunny22 I encountered that when I set more nics in my customization spec than were configured on my template. To remedy that, try converting your template to a powered-off VM, edit-settings, add an additional network device, then convert it back to a template
@djosborne thank you very much ,it works for me as you said, my vm could start, but the network is not available, eth0 or eth1 can not start i have no idea about this i think is someting wrong when i config my customization spec but i not konw how to fix this