Giter VIP home page Giter VIP logo

vagrant-playground's Introduction

Vagrant Playground

This is a Vagrant blueprint that creates an Ansible VM server and one or more VMs as a playground.

It is using static IP, private network and the same SSH key to all VMs. This way we can SSH seamlessly from one VM to another.
Also, updates hosts file to use the hostnames of the VMs by using the vagrant-hostmanager plugin. This apply both on host PC and on VMs
Finally, adds your public SSH key to the guests and combining with static IP of the VMs you can behave them as normal VMs without the need to use vagrant commands; instead of vagrant ssh VM_NAME you can do ssh vagrant@VM_HOSTNAME.

Information

On the first vagrant command it will create the SSH key in the PATH_TO_PROJECT/.ssh that will be used by the VMs instead of the vagrant-auto generated keys (one for every VM). But be careful! Do that only on test environments!.

Also, it will get your HOMEDIR/.ssh/id_rsa.pub public key, and it will add it on the authorized_keys on every VM. Adding your public key on the VMs does not affect the security.

Finally, it will update the hosts file of your computer, and it will do the same for the clients.

Requirements

Get started

Install vagrant-hostmanager plugin

vagrant plugin install vagrant-hostmanager

Clone the project and cd in

git clone https://github.com/tovletoglou/vagrant-playground.git
cd vagrant-playground

Edit the Vagrantfile and uncomment the server/s you like to boot (always keep the ansible.local).
The next example boots the ansible.local and the aegir.local

vm_array = Array[
  ['ansible.local',   '192.168.33.10'],

  ['aegir.local',     '192.168.33.20'],
  #
  # ['haproxy.local',   '192.168.33.30'],
  #
  # ['web1.local',      '192.168.33.31'],
  # ['web2.local',      '192.168.33.32'],
  # ['web3.local',      '192.168.33.33'],
  #
  # ['galera1.local',   '192.168.33.41'],
  # ['galera2.local',   '192.168.33.42'],
  # ['galera3.local',   '192.168.33.43'],
  #
  # ['elastic1.local',  '192.168.33.51'],
  # ['elastic2.local',  '192.168.33.52'],
  # ['elastic3.local',  '192.168.33.53'],
  #
  # ['scrapy.local',    '192.168.33.60'],
  #
  # ['teamcity.local',  '192.168.33.70'],
  #
  # ['swagger.local',   '192.168.33.80'],
  #
  # ['wordpress.local', '192.168.33.90'],
]

It's time to boot up the VMs and wait...

vagrant up

Login to ansible.local VM. It will use your private SSH key stored under your HOME_DIR/.ssh:

Go to the ansible master playbook:

cd ansible-playbook-vagrant-playground

Run the initial playbooks playbook_ansible and playbook_vagrant:

# This playbook will download all the roles used by the included playbooks.
ansible-playbook -i hosts playbook_ansible.yml
# This one will initialize the running VMs. It's not necessary.
ansible-playbook -i hosts playbook_vagrant.yml

And finally the playbook for the server you want to try. For this example we use the playbook_aegir:

ansible-playbook -i hosts playbook_aegir.yml

Now you have and Aegir server to play under 192.168.33.20 or aegir.local.

Cheat sheet

Mount the VMs (on a Linux system)

mkdir ~/[email protected]/
sshfs -o allow_other [email protected]:/ ~/[email protected]/

mkdir ~/[email protected]
sshfs -o allow_other [email protected]:/ ~/[email protected]/

mkdir ~/[email protected]
sshfs -o allow_other [email protected]:/ ~/[email protected]/

Known issues

On Windows systems the hostmanager plugin cannot update the hosts file. If you are experiencing a Ruby error like:

C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/fileutils.rb:1392:in `initialize': Permission denied @ rb_sysopen - C:/Users/USER/.vagrant.d/tmp/hosts.local (Errno::EACCES)

go to the Vagrantfile and change the config.hostmanager.manage_host = true to false.

Then edit manually your hosts file under C:\Windows\System32\drivers\etc.

vagrant-playground's People

Contributors

tovletoglou avatar

Watchers

James Cloos avatar  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.