vagrant-vsphere icon indicating copy to clipboard operation
vagrant-vsphere copied to clipboard

Unable to set static ip address using vagrant-vshpere

Open VarunUmesh opened this issue 10 years ago • 19 comments

I am unable to set static IP address using this plugin. I have the template in vSphere [a vCenter template] and it is a SUSE linux . The VM boots up properly, but IP address does not gets correctly assigned.

The contents of my Vagrantfile looks something like this:

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

config.vm.provider :vsphere do |vsphere , override| override.vm.network 'private_network' , ip: 'xxx.xxx.xxx.xxx' vsphere.customization_spec_name = '<My_Customization_Specification_Manager_In_vSphere>' end

config.vm.provider :vsphere do | vsphere | vsphere.host = 'xxx.xxx.xxx.xxx' vsphere.data_center_name = 'My_DataCenter_Name' vsphere.data_store_name = 'My_Store_Name' vsphere.template_name = 'Template_Name_In_vSphere' vsphere.name = 'Name_Of_The_VM' vsphere.user = '<User Name>' vsphere.password = '<Password>' vsphere.insecure = true vsphere.compute_resource_name = 'xxx.xxx.xxx.xxx' end

I have also made the necessary settings in the Customization Specification Manager part in vShpere. When i see the virtual machine in the console, it fails to bring up the eth0 on the machine.

VarunUmesh avatar Aug 05 '14 22:08 VarunUmesh

vmware guest tools install on that SUSE Linux VM?

henrysher avatar Sep 10 '14 06:09 henrysher

Hi,

Yes. vmware tools were installed on that box.

Thanks!

  • varun

Excuse typos

Sent from Samsung Mobile On 10 Sep 2014 01:58, "Henry Huang" [email protected] wrote:

vmware guest tools install on that SUSE Linux VM?

— Reply to this email directly or view it on GitHub https://github.com/nsidc/vagrant-vsphere/issues/80#issuecomment-55077991 .

VarunUmesh avatar Sep 10 '14 17:09 VarunUmesh

Hi, same problem here.

The VM is a Ubuntu14.04 installed in VSphere, and converted to template. VMWare tools installed, my user has passwordless entry in sudoers. I can boot without error, hostname is correctly set if I don't use customization spec (but IP come from DHCP) If spec is set, the vagrant up never ends.

Here's my configuration:

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

  config.vm.box                     = 'dummy'
  config.vm.box_url                 = './vagrant-vsphere/example_box/dummy.box'
  config.ssh.username               = 'thomas'
  config.ssh.private_key_path       = '/path/to/id_rsa'
  config.ssh.forward_agent          = true
  config.vm.synced_folder           ".", "/vagrant", disabled: true

  config.vm.define "vm1" do |vm1|
    vm1.vm.hostname               = 'vm1'
    vm1.vm.network 'private_network', ip: '192.168.0.200'
    vm1.vm.provider :vsphere do |vsphere|
      vsphere.name                = "vm1"
    end
  end

  config.vm.provider :vsphere do |vsphere|
    vsphere.host                    = '192.168.0.x'
    vsphere.compute_resource_name   = '192.168.0.y'
    vsphere.data_center_name        = 'my-data-center'
    vsphere.template_name           = 'trusty64'
    vsphere.customization_spec_name = 'linux-spec'
    vsphere.user                    = 'root'
    vsphere.password                = 'vmware'
    vsphere.memory_mb               = '2048'
    vsphere.insecure                = true
  end

end

Any idea?

tomav avatar Nov 02 '14 13:11 tomav

I'm having a similar problem. My guest is OS X 10.9.5 and while vagrant-vsphere creates the machine, with the following Vagrantfile it does NOT reassign the IP address of the network adapter:

Vagrant.configure("2") do |config| config.vm.box = 'dummy' config.vm.hostname = "test-experiment" config.vm.network 'private_network', ip: 'XXX.XXX.XXX.XXX'

config.ssh.username = "XXXXXXXX" config.ssh.private_key_path = "key.private" config.ssh.insert_key = "false" config.ssh.forward_agent = true config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.provider :vsphere do |vsphere| vsphere.insecure = 'true' vsphere.host = 'XXXXXXXXX' vsphere.compute_resource_name = 'Compute-1' #vsphere.resource_pool_name = 'YOUR RESOURCE POOL' vsphere.template_name = 'GOLDMASTER' vsphere.name = 'test-experiment' vsphere.user = 'XXXXXXX' vsphere.password = 'XXXXXX' end end

toddc-unity3d avatar Nov 14 '14 01:11 toddc-unity3d

The same issue. Any progress on that?

y4roslav avatar Dec 03 '14 14:12 y4roslav

Negative here. I'm having to configure the IP via Puppet inside the VM kicked off by shellscript from Vagrant. It's ugly, but it gets it done.

toddc-unity3d avatar Dec 03 '14 15:12 toddc-unity3d

I've had some success with this when bringing up Ubuntu12.04 guest OS. It is necessary to specify a customization spec in the Vagrantfile:

vsphere.customization_spec_name = 'my-spec'

Where my-spec refers to a customization spec created in vsphere (see https://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vsphere.vm_admin.doc%2FGUID-C72FA9A6-3871-4838-A4AE-50E218488CD4.html)

From what I've seen, it is necessary to specify the desired IP in the customization spec (the 'prompt user for an address' option results in undefined method ipAddress=' for #<RbVmomi::VIM::CustomizationUnknownIpGenerator:0x000000026970b0> ). I find this rather inconvenient, as I am hoping to consolidate all of my VM creation config into the Vagrantfile, and making a separate customization-spec in vsphere for each VM I manage goes against that.

Anyone have any idea how to create a single customization spec that will allow vagrant to specify the IP?

dylancwood avatar Jan 04 '15 08:01 dylancwood

Update, it appears that the IP address specified in the Vagrantfile will override whatever IP is specified in the VMWare customization-spec.

dylancwood avatar Jan 04 '15 08:01 dylancwood

Same issue here - any plans on fixing this?

pforai avatar Aug 13 '15 14:08 pforai

I think setting a static IP address with this solution only works if vSphere supports guest OS customization for that particular OS. There is a support matrix on vmware.com with a list of guest OS's and vSphere releases that work together with customization specs: http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf

It sounds like @dylancwood is on the right track. I would highly suggest reading through the vSphere documentation he linked (above) about setting up customization specs and perhaps testing your deployments through the vSphere client before attempting them with vagrant-vsphere.

To my knowledge, vagrant-vsphere doesn't do any network customization itself. It just overrides the IP address used by vSphere during its guest OS customization process.

jwbraucher avatar Aug 13 '15 16:08 jwbraucher

Agreed, it looks like the guest OS has to support that. It may be ugly but something that works for me is to write a wrapper script that in addition to firing up a machine SSH's in and reconfigures that part, THEN runs Puppet or anything else I need. It's not pretty, but on OSes that don't support customization you're kinda stuck.

toddc-unity3d avatar Aug 13 '15 17:08 toddc-unity3d

Okay, another work around would be to have a DHCP server installed which would give the IP addresses when you clone the virtual machine and then do a vagrant provisioning [https://docs.vagrantup.com/v2/provisioning/shell.html], which allows you to make configurations after the vagrant up command. Thus you would be using your DHCP only temporarily and then assign the required IP after boot up

VarunUmesh avatar Aug 13 '15 21:08 VarunUmesh

@jwbraucher is correct, setting a static IP using :private_network and specifying a customization spec requires that vsphere supports guest OS customization for your OS version. The VM must also have vmware tools installed for guest customization to work, and minimum VM version requirements apply to.

If you are having problems with this feature, please state:

  • Your vCenter version (including update level)
  • OS Version
  • vmware tools version
  • vm version

rylarson avatar Aug 31 '15 16:08 rylarson

I am also experiencing the same issue with the following.

vSphere 6.0 Ubuntu 14.04 as the VM OS Mac OS X 10.11 as the vagrant workstation open-vm-tools 9.4.0

karnold avatar Oct 20 '15 02:10 karnold

@karnold What VM hardware version is your guest OS?

rylarson avatar Oct 20 '15 03:10 rylarson

VM Hardware version 11

karnold avatar Oct 20 '15 04:10 karnold

so I have same problem I have also made the necessary settings in the Customization Specification Manager part in vShpere. When i see the virtual machine in the console, it fails to bring up the eth0 on the machine. and i can bring up eth0 by ifup etho command. is some thing wrong with my Customization Specification. thank you for any help

simsunny22 avatar Jan 26 '16 06:01 simsunny22

problem exist - does anyone planning to check it ?

doker78 avatar May 24 '17 17:05 doker78

I run into same issue with Centos8 base image.

After one day research I found a working workflow.

  1. Install a Centos 8 image from a ISO. During the install choose a custom IP setting ( not DHCP)
  2. After the machine is setted up login via ssh and execute the folowing commands
dnf update -y
dnf clean all
systemctl start vmtoolsd.service
systemctl enable vmtoolsd.service
rm -vf /etc/ssh/ssh_host_*
dnf install -y perl
systemctl stop systemd-journald.socket
find /var/log -type f -exec rm {} \;
mkdir -p /var/log/journal
cd /root ; rm -f .bash_history ; history -c
systemctl poweroff
  1. Convert the machine to a template
  2. Create a VM Customization Specifications with a static IP.

suikast42 avatar Feb 19 '20 10:02 suikast42