Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Install, and setup Vagrant VM #4
Comments
|
First we install vagrant, virtualbox, and download an image of Ubuntu Server 14.04: wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb
sudo dpkg --install vagrant_1.7.2_x86_64.deb
sudo apt-get install virtualbox
sudo apt-get install dkms
sudo mkdir /var/iso_images/
cd /var/iso_images/
wget http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-server-i386.isoNote: the above ubuntu image is equivalent to eventually After assigning the installed ubuntu iso image to a VM instance, we get the following error when attempting to run the Ubuntu VM instance:
Quick research yields a suggestion to enable Note: In our case, we had to press the Note: the entered bios window, contained the following descriptive help text:
|
|
After starting up the VM instance, we install the corresponding Ubuntu iso image, therefore, define the following settings:
Vagrant assumes an account with default settings (i.e. username, and password) to exist within the operating system. Specifically, It will assume a username by Also, vagrant doesn't actually use, or expect any root password. However, having a generally well known root password makes it easier for the general public to modify the machine if needed. Also, publicly available base boxes usually use a root password of vagrant to keep things easy. |
|
Guest Additions Generally, it is recommended to install Virtualbox guest additions to add the following features:
The following will install guest additions on the Ubuntu guest: sudo apt-get install virtualbox-guest-x11Note: for best performance with USB devices, ensure VirtualBox extension pack is installed, and the same version as the VirtualBox. Sudoless User Sometimes, users can find entering password a hassle. To accommodate, the following will allow the visudoThen add the following to the end of the file:
Note: generally, after running the |
|
Recall that vagrant communicates from the host, to the guest machine over SSH. Therefore, this process requires a public, and private key. However, if the vagrant base box is to be distributed publicly, then both the public, and private key will need to be known by everyone. This means the vagrant will use an insecure key-pair. The following steps sets up the public key on the base box: mkdir -p /home/vagrant/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
# Ensure we have the correct permissions set
chmod 0700 /home/vagrant/.ssh
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.sshThis will allow the base box (containing the public key) to communicate with vagrant (containing the insecure private key). Also, according to the vagrant documentation, it is important to implement the exact file permission changes, since OpenSSH is very strict. Note: vagrant documentation suggests using insecure key-pair. Note: for a more secure setup, remove the trusted key from ~vagrant/.ssh/authorized_keys, create a custom key-pair, then configure the private key in the Vagrantfile with |
|
Now, we should be able to create a Vagrant Base Box: vagrant package –-base <VitualBox VM Name>This box now can be shared via:
The latter approach is generally easier via the web-interface. However, it can be accomplished on the command line via the Atlas API. Installing Box: from Atlas cd [choose_directory]/
vagrant box add jeff1evesque/mybox
vagrant init --force --minimal jeff1esque/mybox
vagrant upNote: replace Alternatively, if the box may reside on an alternate location: vagrant box add ubuntu/trusty64
vagrant init ubuntu/trusty64
vagrant upInstalling Box: from Local cd [choose_directory]/
vagrant add /path/to/mybox
vagrant init
vagrant upNote: It is important to know, that the Note: the Note: an alternative to creating a custom box, is to use preconfigured boxes by Atlas. |
|
After cloning a git repository (containing a Therefore, modifying the git repository on the VM, would modify the same mounted directory on the host machine. This is one way to pass files into the box for pre-puppet (or chef) build (i.e. shell provisioner). |
|
We temporarily comment out the minimal gnome-ui installation from # git: install git if not 'present'.
class git {
package {'git':
ensure => present,
}
}
# gnome ui: install gnome-ui if not 'present' (double quote needed).
class gnome {
$gnome_packages = ["xorg", "gnome-core", "gnome-system-tools", "gnome-app-install"]
# package {$gnome_packages:
# ensure => present,
# }
}
# implement classes
include git
include gnomeAfter executing $ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: iScanner_default_1429966863487_9782
==> 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 => 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: Warning: Connection timeout. 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 insercure key from the guest if its present
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/Jeffrey/iScanner
default: /tmp/vagrant-puppet/manifests-a11324675765e76f66557bd3efb87767dde3 => C:/Users/Jeffrey/iScanner/manifests
==> default: Running provisioner: puppet...
==> default: Running Puppet with default.pp...
==> default: stdin: is not a tty
==> default: Notice: Compiled catalog for vagrant-ubuntu-trusty-64.wp.comcast.net in environment production in 0.18 seconds
==> default: Notice: /Stage[main]/Git/Package[git]/ensure: ensure change 'purged' to 'present'
==> default: Notice: Finished catalog run in 10.97 secondsHowever, the VM box we created (Ubuntu Server) is initially running, and does not have a corresponding window. So, we goto the Virtualbox Manager, and explicitly However, when navigating to the Note: the host machine is windows 7, the guest is ubuntu Server 14.04, Also, we have VirtualBox 4.3.26, as well as Vagrant 1.7.2. Note: despite the above confusing output regarding git |
|
When we uncomment the following lines from our ...
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
end
...Then, each time we run Note: uncommenting the However, if we The reason for this, is because vagrant provisions the VM (guest), which includes mounting the directory between the host, and the guest To remedy this problem: if the VM is rebooted, or powered off, then either two commands must be made on the host machine, in order to synch the shared (mounted) directory:
It is important to know that virtual machines should be destroyed via Vagrant, and not the virtual machine wrapper (i.e. VirtualBox, VMware). Instead, the command |

jeff1evesque commentedApr 21, 2015
Since we intend to develop non-UI logic with C++ (Objective-C for front-end), we will develop within a linux virtual machine. This will allow us to separate dependencies from different projects, and easier to deploy in a minimalistic fashion (not installing unneeded packages). Specifically, we will install, and setup Vagrant.
Note: this issue corresponds to jeff1evesque/machine-learning#1393.