Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set static ip address using vagrant-vshpere #80

Open
VarunUmesh opened this issue Aug 5, 2014 · 19 comments
Open

Unable to set static ip address using vagrant-vshpere #80

VarunUmesh opened this issue Aug 5, 2014 · 19 comments

Comments

@VarunUmesh
Copy link

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 = ''
vsphere.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.

@henrysher
Copy link
Contributor

vmware guest tools install on that SUSE Linux VM?

@VarunUmesh
Copy link
Author

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" notifications@github.com wrote:

vmware guest tools install on that SUSE Linux VM?


Reply to this email directly or view it on GitHub
#80 (comment)
.

@tomav
Copy link

tomav commented Nov 2, 2014

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?

@toddc-unity3d
Copy link

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

@y4roslav
Copy link

y4roslav commented Dec 3, 2014

The same issue. Any progress on that?

@toddc-unity3d
Copy link

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.

@dylancwood
Copy link

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
Copy link

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

@pforai
Copy link

pforai commented Aug 13, 2015

Same issue here - any plans on fixing this?

@jwbraucher
Copy link

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.

@toddc-unity3d
Copy link

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.

@VarunUmesh
Copy link
Author

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

@rylarson
Copy link
Contributor

@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

@karnold
Copy link

karnold commented Oct 20, 2015

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

@rylarson
Copy link
Contributor

@karnold What VM hardware version is your guest OS?

@karnold
Copy link

karnold commented Oct 20, 2015

VM Hardware version 11

@simsunny22
Copy link

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

@doker78
Copy link

doker78 commented May 24, 2017

problem exist - does anyone planning to check it ?

@suikast42
Copy link

suikast42 commented Feb 19, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests