nsidc / vagrant-vsphere

VMware vSphere provider for Vagrant
Other
608 stars 166 forks source link

Not able to run provisioners on the cloned VM #256

Open deepakmalik85 opened 6 years ago

deepakmalik85 commented 6 years ago

I have installed the vagrant-vsphere plugin. After following the steps mentioned in the doc, I am able to connect to ESXI host and cloned the machine.

Vagrant file

VAGRANT_INSTANCE_NAME   = "VM152"

Vagrant.configure("2") do |config|
  config.vm.box     = 'vsphere'
  config.vm.box_url = '/home/abc/.vagrant.d/gems/2.3.4/gems/vagrant-vsphere-1.13.2/example_box/dummy.box'

  config.vm.hostname = VAGRANT_INSTANCE_NAME
  config.vm.define VAGRANT_INSTANCE_NAME do |d|
  end

  config.vm.provider :vsphere do |vsphere|
    vsphere.host                  = 'ttyrvms02.lab.com'
    vsphere.name                  = VAGRANT_INSTANCE_NAME
    vsphere.compute_resource_name = '10.X.X.X'
    vsphere.resource_pool_name    = 'VMA'
    vsphere.template_name         = 'VMA152Relv1'
#    vsphere.vm_base_path          = "vagrant-machines"

    vsphere.user     = 'abc@lab.com'
    vsphere.password = 'XXXXXXX'
    vsphere.insecure = true

#    vsphere.custom_attribute('timestamp', Time.now.to_s)
  end
   config.vm.provision "SanityTest", type: "shell", path: "/home/abc/Sanity/VMASanityTest.sh"
   config.vm.provision "Functioncheck", type: "shell", path: "/home/SDF/DDS/function.sh"

With Virtual box, I used to run provisioners using

vagrant up VM152 --provision-with SanityTest

But running my shell provisioners on the cloned machine (same way as above) is not supported

==> VM152: Calling vSphere CloneVM with the following settings:
==> VM152:  -- Template VM: Cluster1/vm/VM152Relv1
==> VM152:  -- Target VM: Cluster1/vm/VM152
DuplicateName: The name 'VM152' already exists.

What should I do to execute provisioners on the cloned VM ?