Difference between revisions of "HashiCorp/Vagrant"

From Ever changing code
Jump to navigation Jump to search
(Created page with "= Getting started = Create Vagrant project, by creating ''Vagrantfile'' in your current directory vagrant init Add boxes (standard VMs from providers in Virtualbox, VMware o...")
 
Line 7: Line 7:
  #Box can be specified via URLs or local file paths
  #Box can be specified via URLs or local file paths
  vagrant box add --force <span style="color: green">ubuntu/14.04</span> <nowiki>https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box</nowiki>
  vagrant box add --force <span style="color: green">ubuntu/14.04</span> <nowiki>https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box</nowiki>
vagrant box add --force ubuntu/14.04-i386 https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-i386-vagrant-disk1.boxvi


Configure Vagrantfile to use the box as your base system
Configure Vagrantfile to use the box as your base system
Line 12: Line 13:
   config.vm.box = "<span style="color: green">ubuntu/14.04</span>"
   config.vm.box = "<span style="color: green">ubuntu/14.04</span>"
  end
  end
;Power up your Vagrant box
vagrant up
Error:
''Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.''
The error above is due to Virtualbox cannot run nested 64bit virtualbox VM. Spinning up a 64bit VM stops with an error that no 64bit CPU could be found.
<source lang=bash>
piotr@vm-ubuntu64:~/git/vagrant$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/14.04-i386'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrant_default_1456318357740_51238
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (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: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH 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.1.44
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /home/piotr/git/vagrant
</source>
;Shared directory between Vagrant VM and an hypervisor provider
Vagrant shares a directory at /vagrant with the directory on the host containing your Vagrantfile
Delete Vagrant VM
vagrant destroy
Delete downloaded Vagrant VM image file
vagrant box remove


= Resources =
= Resources =

Revision as of 15:00, 24 February 2016

Getting started

Create Vagrant project, by creating Vagrantfile in your current directory

vagrant init

Add boxes (standard VMs from providers in Virtualbox, VMware or Hyper-V format)

vagrant box add hashicorp/precise64        #username: hashicorp boximage: precise64, this is preconfigured repository
#Box can be specified via URLs or local file paths
vagrant box add --force ubuntu/14.04 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
vagrant box add --force ubuntu/14.04-i386 https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-i386-vagrant-disk1.boxvi 

Configure Vagrantfile to use the box as your base system

Vagrant.configure("2") do |config|
 config.vm.box = "ubuntu/14.04"
end
Power up your Vagrant box
vagrant up

Error: Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly, as well.

If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.

The error above is due to Virtualbox cannot run nested 64bit virtualbox VM. Spinning up a 64bit VM stops with an error that no 64bit CPU could be found.

piotr@vm-ubuntu64:~/git/vagrant$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/14.04-i386'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrant_default_1456318357740_51238
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (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: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH 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.1.44
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /home/piotr/git/vagrant
Shared directory between Vagrant VM and an hypervisor provider

Vagrant shares a directory at /vagrant with the directory on the host containing your Vagrantfile

Delete Vagrant VM

vagrant destroy

Delete downloaded Vagrant VM image file

vagrant box remove

Resources