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

DuplicateName exists: plugin cannot find current Powered On VMs using Multi-machine Loop #202

Open
ayen-tibco opened this issue Sep 14, 2016 · 3 comments

Comments

@ayen-tibco
Copy link

During my CI build, the .vagrant directory was accidentally delete while my VMs are still running on my ESXi, I need to rebuild the .vagrant and have vagrant up detect the current running VMs. But to no avail I can't get it running with my current multi-machine Vagrantfile. Any suggestions besides manually deleting my VMs and recreating them again?

vagrant version
Installed Version: 1.8.5
Latest Version: 1.8.5
vagrant-vsphere (1.10.0)
vSphere: 6.0U2

vagrant status
ERROR loader: Unknown config sources: ["21248980_machine_instance-1"]
ERROR loader: Unknown config sources: ["21248980_machine_instance-1"]
ERROR loader: Unknown config sources: ["21248980_machine_instance-1", "21248980_machine_instance-2"]
ERROR loader: Unknown config sources: ["21248980_machine_instance-1", "21248980_machine_instance-2"]
ERROR loader: Unknown config sources: ["21248980_machine_instance-2", "21248980_machine_instance-3"]
ERROR loader: Unknown config sources: ["21248980_machine_instance-1", "21248980_machine_instance-3"]
ERROR loader: Unknown config sources: ["21248980_machine_instance-1", "21248980_machine_instance-2"]
Current machine states:

instance-1 vagrant_vsphere.states.short_not_created (vsphere)
instance-2 vagrant_vsphere.states.short_not_created (vsphere)
instance-3 vagrant_vsphere.states.short_not_created (vsphere)

Vagrantfile:

Vagrant.require_version ">= 1.7.0"
cluster_machine_names=Array.new
unless Vagrant.has_plugin?("vsphere")
  raise 'vagrant-vsphere is not installed! Enter [vagrant plugin install vagrant-vsphere] to install.'
end

Vagrant.configure(2) do |config|
    # Disable the new default behavior introduced in Vagrant 1.7, to
    # ensure that all Vagrant machines will use the same SSH key pair.
    # See https://github.com/mitchellh/vagrant/issues/5005
    config.ssh.insert_key = false
    config.ssh.username = "vagrant"
    config.ssh.private_key_path = './example_box/vagrant_private.key'
    config.ssh.pty = true
    config.vm.box = "vsphere.box"
    config.vm.box_url = "example_box/vsphere.box"

    # Vsphere defaults
    config.vm.provider :vsphere do |vsphere|
        vsphere.host = 'somevcenterhost'
        vsphere.compute_resource_name = 'someesxihost'
        vsphere.resource_pool_name = ''
        vsphere.template_name = 'centos7'
        vsphere.user = '[email protected]'
        vsphere.password = 'somepassword'
        # If you don't have SSL configured correctly, set this to 'true'
        vsphere.insecure = true
        vsphere.memory_mb = 4096
        vsphere.cpu_count = 2
    end
    N=3
    (1..N).each do |i|
        config.vm.define "instance-#{i}" do |instance|
            ins
https://guides.github.com/features/mastering-markdown/tance.vm.hostname = "instance-#{i}"
            cluster_machine_names << "instance-#{i}"
            instance.vm.network "private_network", type: "dhcp"
            # forwarded port doesn not work with vsphere plugin yet
            # instance.vm.network "forwarded_port", guest: 5556, host: host_admin_ports[N], auto_correct: true
            instance.vm.provider :vsphere do |vsphere|
                vsphere.name = "instance-#{i}"
            end

            # trick to get playbook run only once with parrallelism
            if i == N
                instance.vm.provision "ansible" do |ansible|
                    ansible.verbose = "v"
                    ansible.limit = "all"
                        # perform the entire deployment or custom tags
                        ansible.playbook = "playbooks/someplaybook.yml"
                    end
                end
           end
        end
    end
end

Debug Output:
vsphere.txt

@taliesins
Copy link
Contributor

You might want the changes in #210 and then retry this.

@ayen-tibco
Copy link
Author

Tested with #210 and doesn't resolve existings VMs created from prior vagrant up.

$ vagrant up A1
Bringing machine 'A1' up with 'vsphere' provider...
==> A1: Setting custom memory: 4096
==> A1: Setting custom cpu count: 2
Progress: 18%DuplicateName: The name 'A1' already exists.

$ vagrant status
Current machine states:

A1 not created (vsphere)
A2 not created (vsphere)

@taliesins
Copy link
Contributor

Interesting. I don't think I affected anything around this.

I am thinking perhaps it's related to the state folder that is created for each vm by vagrant. I don't remember seeing anywhere a validation to see if the name already exists on vsphere.

Did you run vagrant up with this branch and then run it again and it failed? Or did you have a vm created with a previous branch and then used vagrant up.

I will look into it!

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

2 participants