Monday, December 26, 2016

Creating multiple VM using Vagrant

This is a sample configuration for vagrant to create custom stack of servers.

Steps1. create file  "Vagrantfile"

require 'yaml'
records = YAML.load_file('config.yaml')
$x = records['server_name'].size
puts "You have asked to install #{$x} of systems "
puts "#{records['server_name']}"
cluster  = {}
(0..($x-1)).each do |i|
cluster["hostname" => "#{records['server_name'][i]['hostname']}" , "ip" => "#{records['server_name'][i]['ip']}"]="hostname-#{i}"
Vagrant.configure(2) do |config|

  cluster.each_with_index do |(info, hostname), index|

    config.vm.define hostname do |cfg|
      cfg.vm.provider :virtualbox do |vb, override| = "centos/7"
override.vm.synced_folder '.', '/vagrant' , type: "virtualbox" :private_network, ip: "#{info['ip']}"
        override.vm.hostname = "#{info['hostname']}" = "#{info['hostname']}"
override.vm.provision "ansible_local" do |ansible|
ansible.playbook = "playbook.yaml"
      end # end provider
    end # end config

  end # end cluster

step 2. Create file config.yaml ( --- also needs to include )

         - hostname: "webserver"
           ip: ""
         - hostname: "database"
           ip: ""
         - hostname: "appserver"
           ip: ""

step3. place one sample "playbook.yaml" file

- hosts: all
  become: yes
    - name: ensure ntpd is at the latest version
      yum: pkg=ntp state=latest
      - restart ntpd
    - name: restart ntpd
      service: name=ntpd state=restarted

step4. run "vagrant up"

Note:  I got some issues while  starting vagrant related to sharing the directory to guest vm. At that time I used following command to resolve it.    "vagrant plugin install vagrant-vbguest "

Please test it and send me if there is any issues. 

Thursday, October 27, 2016


to get host inventory 
- name: Install this only for local dev machine
  pip: name=pyramid
  when: inventory_hostname == "local"
     instead of inventory_hostname , can use group_names to get individual group
copy command fails for large files use synchronize
    - name: Transfer file from ServerA to ServerB
        src: /path/on/server_a
        dest: /path/on/server_b

Monday, October 24, 2016


Vagrant is a tool to create development environment quickly. Suppose if your application need an environment which contains web, app, db, lb tiers, so creating virtual systems manually will take more time. Since vagrant keeps its configuration you can create these environments quickly.

for more details what it does, go through the documents when ever you get time. But I think we can  jump to some practice .

1. Download Vagrant from :
2. Download putty and putty keygen ( if you are trying out in windows)
3. Oracle Virtualbox .

To start with we need a box. Box is nothing but the package for vagrant to create environment. ie if you want to create an Ubuntu VM  , you need to get one Ubuntu box image. You can find it in

example: ubuntu/trusty64

Now the tools and other stuffs are ready with us. Install above listed 3 items. If your system ask for restart , obey it no other way :)

Once you set it up we can go for next step

vagrant is the command using to manage the boxes . if you simply type vagrant in command prompt and type enter you will get the options and parameters.

Usage: vagrant [options] []

    -v, --version                    Print the version and exit.
    -h, --help                       Print this help.

Common commands:
     box             manages boxes: installation, removal, etc.
     connect         connect to a remotely shared Vagrant environment
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrant file
     login           log in to HashiCorp's Atlas
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     share           share your Vagrant environment with anyone in the world
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     version         prints current and latest Vagrant version

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.

Now we can use option box

>vagrant box 

Usage: vagrant box []

Available subcommands:

For help on any individual subcommand run `vagrant box -h`

Now it is expecting a box image name

>vagrant box add ubuntu/trusty64

The above command will download a box image  and will cache in your system.
Now you can create a new VM configuration with this box image by

>vagrant init ubuntu/trusty64

This will create a Vagrant configuration file in the local directory with this ubuntu/trusty64 box image

>vagrant up

the above command will start VM with the configuration which created in above steps

>vagrant list

will list out the boxes running presently

you can ssh to the started VM though port 2222 ( if you run multiple boxes it will change, see the logs while you starting the VM)

Tuesday, April 26, 2016

[JMETER] could not initialise key store >> illegal option: -ext

could not initialise key store >> illegal option: -ext in

This issue is because of wrong Java version . Use JDK 7 ( jdk1.7.X) . 

Which operating system you like most?