tknerr / vagrant-managed-servers

Enables Vagrant to ssh into and provision managed servers
MIT License
185 stars 30 forks source link

Manage multiple physical servers #70

Closed harmanbirdi closed 7 years ago

harmanbirdi commented 7 years ago

I have managed to get this working with a single physical server, but we have need to be able to manage a group of physical servers and to be able to provision them using the same playbook.

Is it possible to manage multiple physical boxes using this plugin? If so, could you please point me to the documentation or examples? I could only find documentation on managing one managed.server

Thanks

tknerr commented 7 years ago

Hi @harmanbirdi , you can definitely do something like this:


Vagrant.configure("2") do |config|

  # defaults for all the VMs below
  config.vm.provider :managed do |_, override|
    override.vm.box = "tknerr/managed-server-dummy"
    override.ssh.username = "foo"
    override.ssh.private_key_path = "#{ENV['HOME']}/.ssh/id_rsa_foo"
  end

  # Jenkins master
  config.vm.define "master" do |master|
    master.vm.provider :managed do |managed_config, override|
      managed_config.server = "jenkins.my.org"
    end
    master.vm.provision "shell", inline: "echo 'installing jenkins master...'"
  end

  # Jenkins slaves
  (1..2).each do |num|
    config.vm.define "slave0#{num}" do |slave|
      slave.vm.provider :managed do |managed_config, override|
        managed_config.server = "slave0#{num}.my.org"
      end
      slave.vm.provision "shell", inline: "echo 'installing jenkins slave0#{num}...'"
    end
  end

end
harmanbirdi commented 7 years ago

I did manage to integrate the plugin into what I was trying to do. However, I am seeing another issue. Will open up a new issue for that. Thanks.