0 Replies Latest reply on Feb 12, 2015 10:38 AM by bryantp2

    Using Vagrant with VMware VSphere

    bryantp2 Lurker

      Hello All,


      I am trying to use Vagrant to provision a VM using VSphere. I am able to get the machine to provision and start up, but I noticed that Vagrant is unable to connect to the virtual machine once it has started. I have tracked this down to the hostname not updating. If I restart the VM, the hostname change takes effect. I am using a Custom Specification to change the VM's hostname upon provisioning. I have VMWare Tools installed on the Template and the Operating System is Debian 7.


      For reference, I am using this plugin to utilize VSphere with Vagrant. Here is my VagrantFile


      username = nil
      password = nil
      if File.exist?("config.yml")
          require 'yaml'
          config = YAML::load(File.open('config.yml'))
          username = config['username']
          password = config['password']
      Vagrant.configure("2") do |config|
        config.vm.box     = 'vsphere'
        config.vm.box_url = 'https://vagrantcloud.com/ssx/boxes/vsphere-dummy/versions/0.0.1/providers/vsphere.box'
        config.vm.hostname = ENV['USERNAME'].downcase + "-cmui"
        config.vm.provision "shell", inline: "hostname " + config.vm.hostname
        config.vm.provision "shell", inline: "service network restart"
        config.vm.provider :vsphere do |vsphere|
          vsphere.host                    = ''
          vsphere.compute_resource_name   = 'Dev cluster'
          vsphere.template_name           = 'cm_dev_ui_template'
          vsphere.name                    = ENV['USERNAME'].downcase + "-cmui"
          vsphere.user                    = username
          vsphere.password                = password
          vsphere.insecure                = true
          vsphere.customization_spec_name = "cm-ui-dev"


      Thanks for any help.