Saturday 28 June 2014

vagrant

vagrant installation:

1. Install the virtual box.
2. Download the vagrant code from website and install the same.
 

3.
  $ vagrant box add hashicorp/precise32 http://files.vagrantup.com/precise32.box
  $ vagrant init hashicorp/precise32
  $ vagrant up


4.$ vagrant box add hashicorp/precise32 http://files.vagrantup.com/precise32.box
==> box: Adding box 'hashicorp/precise32' (v0) for provider:
    box: Downloading: http://files.vagrantup.com/precise32.box
==> box: Successfully added box 'hashicorp/precise32' (v0) for 'virtualbox'!
 

amit@laptop:~$ vagrant init hashicorp/precise32
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
 

amit@laptop:~$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: amit_default_1403959296506_47328
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.1
==> default: Mounting shared folders...
    default: /vagrant => /home/amit
amit@laptop:~$


5: Now from few of the above point you can get that:

The virtual box is listening on port 2222 on 127.0.0.1 and default user is "vagrant" password is "vagrant".
You can create your PKI for this. [ if you see your virtual machine, you can see a vm is running. ]

6. How do I login: [ vagrant ssh ]

ssh -p 2222 vagrant@127.0.0.1  #password is vagrant.  [ this is old way. ]


7. vagrant suspend  [ saved current state of the instance. ]
8. vagrant resume   [ resume a previously suspended instance. ]
9. vagrant halt [ to stop the vm instance ]
10. vagrant up [ power on the vm machine. ]

11. start from scratch:
 a. vagrant destroy
 b. vagrant up

12. vagrant ssh [ to ssh into the vagrant box. ]


##
$ vagrant --help
Usage: vagrant [options] <command> [<args>]

    -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 Vagrantfile
     login           log in to Vagrant Cloud
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     provision       provisions the vagrant machine
     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
     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`.

##

No comments:

Post a Comment