Vagrant: Difference between revisions
From charlesreid1
| Line 22: | Line 22: | ||
</pre> | </pre> | ||
== | ==Basic Startup Shutdown Procedure== | ||
===Start Vagrant Machine=== | |||
Create a directory for your vagrant virtual boxes: | Create a directory for your vagrant virtual boxes: | ||
| Line 37: | Line 39: | ||
$ vagrant up | $ vagrant up | ||
</pre> | </pre> | ||
==Connect to Vagrant Machine=== | |||
Now you can ssh into the new virtual machine using | Now you can ssh into the new virtual machine using | ||
| Line 65: | Line 69: | ||
If multiple virtual machines, each node should have same values except for SSH key. | If multiple virtual machines, each node should have same values except for SSH key. | ||
===Manually Connect to Vagrant Machine=== | |||
using the key printed from the above command, you can SSH manually using that key: | |||
<pre> | <pre> | ||
| Line 74: | Line 80: | ||
Note that everything vagrant-related is stored in the <code>.vagrant/</code> directory. | Note that everything vagrant-related is stored in the <code>.vagrant/</code> directory. | ||
===Stopping Vagrant Machine=== | |||
To stop the machine, run vagrant halt: | |||
<pre> | |||
$ vagrant halt | |||
</pre> | |||
=Flags= | =Flags= | ||
[[Category:Vagrant]] | [[Category:Vagrant]] | ||
Revision as of 01:27, 5 November 2018
Vagrant is an open source tool for managing virtual machines.
Related: Ansible
What is it
Think of Vagrant like a command line interface for VirtualBox.
Vagrant has built-in support for Ansible.
Installing
Start by installing VirtualBox, then install Vagrant from http://www.vagrantup.com/
Mac OS X
On OS X, use Homebrew to install both VirtualBox and Vagrant:
$ brew cask install virtualbox $ brew cask install vagrant $ brew cask install vagrant-manager
Basic Startup Shutdown Procedure
Start Vagrant Machine
Create a directory for your vagrant virtual boxes:
$ mkdir playbooks $ cd playbooks
From there you can run the vagrant init command to initialize the virtual machine using Vagrant (the first time you run vagrant init it will have to download the virtual machine, which could take a while):
$ vagrant init ubuntu/trusty64 $ vagrant up
Connect to Vagrant Machine=
Now you can ssh into the new virtual machine using
$ vagrant ssh
To see the SSH details, type:
$ vagrant ssh-config Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /Users/whoami/dev/ansiblebook/ch01/playbooks/.vagrant/machines/default/virtualbox/private_key IdentitiesOnly yes LogLevel FATAL
(this should be run from the host machine.)
If multiple virtual machines, each node should have same values except for SSH key.
Manually Connect to Vagrant Machine
using the key printed from the above command, you can SSH manually using that key:
$ ssh vagrant@127.0.0.1 -p 2222 -i $HOME/dev/ansible/dev/ansiblebook/ch01/playbooks/.vagrant/machines/default/virtualbox/private_key
This will log you in without prompting for a password.
Note that everything vagrant-related is stored in the .vagrant/ directory.
Stopping Vagrant Machine
To stop the machine, run vagrant halt:
$ vagrant halt