devopsgroup-io / vagrant-hostmanager

:pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.
Mozilla Public License 2.0
1.46k stars 146 forks source link

Hosts keep getting replaced #249

Open crazycodr opened 6 years ago

crazycodr commented 6 years ago

I made a completely variable setup that allows me to generate similar machines but the names, hostname, etc are controlled by startup flags.

namespace="learningbird"
ssh_user="lb-user"
machine_type="app"
begin
    opts.each do |opt, arg|
        case opt
            when '--namespace'
                namespace=arg
            when '--machine-type'
                machine_type=arg
        end
    end
rescue GetoptLong::InvalidOption => e
    # Do nothing, we want vagrant to process its own parameters too
end

This allows me to have only one definition in my file like so:

    config.vm.define "#{namespace}-#{machine_type}", primary: true do |definition|

But because of that, i think, the machines that hostmanager sees are always and only the 1 machine that i brought up. So this means that my hosts file is always getting rewritten with the latest machine i am bringing up which is kinda annoying.

Is there anything i can do about that?

crazycodr commented 6 years ago

Also, when i use machine-type or namespace parameter, it says at the end

==> dan-queue: Running provisioner: hostmanager...
The machine with the name 'dan-queue' was not found configured for
this Vagrant environment.