Giter Site home page Giter Site logo

spivegin / vagrant-multi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashayh/vagrant-multi

0.0 1.0 0.0 114 KB

Create multiple VMs with Vagrant, and manage their hosts files through puppet for hostname resolution.

Puppet 75.08% Ruby 8.01% HTML 16.91%

vagrant-multi's Introduction

vagrant-multi

** One should now only use the hostsmanager plugin, or other such options: https://github.com/smdahlen/vagrant-hostmanager **

Create multiple VMs with Vagrant, and manage their hosts files through puppet for hostname resolution.

It is easy to spin up custom multi VM environments using Vagrant. Vagrant also lets you assign friendly 'names' which you can use to ssh to the VMs from the host. This is convenient, but is not useful inside the guests.

What if you want the VMs to talk to each other using hostnames? You could run your own DHCP/DNS servers, but maintaining additional tools can become a chore. You could be using Foreman or Cobbler for this, but then, this is post about Vagrant.

One other way is to maintain an /etc/hosts file with each VMs name and IP. One simple solution for this task, is to symlink /etc/hosts to a file on the shared folder that vagrant can create for you.

So you can have this line inside your Vagranfile, which is applied to each VM:

vm_name.vm.provision :shell, :inline => "sudo ln -fs /vagrant/etc-hosts /etc/hosts"

The nice thing is, you can read this etc-hosts file inside your Vagrantfile, and use it to create your Multi-VM setup. You can do this before the Vagrant::Config.run do loop inside the Vagrantfile.

Now what if you wanted additional customization for each VM, say different memory sizes, or even operating systems? You could add special comments/lines in the file for that. But this is how I chose to solve this, when creating a multi-VM setup for the ambari environment:

  • Create a "hosts.yaml" file with a list of your hosts, and their attributes, like name, memory, ip address. Should be easy to extend with more attributes.
  • Get this puppet module for managing hosts files.
  • Read the "hosts.yaml" file through your Vagrantfile, and create another file called "common.yaml", which the puppet module can use through hiera.
  • Use the attributes you added in "hosts.yaml" to create your multi-VM setup.

The resulting setup is available on github here.

There are some Ambari related things in the puppet code, most of which I have commented out. Without the Ambari related code, this is one way to manage hosts files in your multi-VM setup.

vagrant-multi's People

Contributors

ashayh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.