Vagrant

From Wildsong
Revision as of 18:47, 24 January 2016 by Brian Wilson (talk | contribs)
Jump to navigationJump to search

"Vagrant" is a system for managing virtual machines.

http://vagrantup.com/

You set up a config file that sets up the vm, including installing packages and configuration settings.

Normally I run Parallels to use virtual machines on my Mac, but as of version 11, I have to pony up another $20 to get the pro version for Vagrant, and there is no current Debian provider. So I am going back to using VirtualBox for now.

Running a squid proxy

I put a proxy on Bellman so that I don't have to pull every DEB package over the Internet every time I create a new Vagrant machine.

apt-get install squid-deb-proxy squid-deb-proxy-client

On each client you can install the avahi client software and it will automatically find the server.

apt-get install squid-deb-proxy-client

The debian proxy runs on port 8000, the standard squid proxy runs on 3128 If you want to use squid as well as the dpkg cache then you need to edit /etc/squid3/squid.conf to add an acl -- acl localnet 192.168.1.0/24 for example

Building a custom box

All the details

https://blog.engineyard.com/2014/building-a-vagrant-box

Refinement: Make the virtual hard drive smaller, there is no earthly reason for it to be 40GB. The default 8GB is big enough, in fact 4GB would be fine.

Quick version

  1. Build a virtualbox. Use a 4GB VMDK drive. Turn off audio and USB, put the network interface in bridged mode so it gets a real IP.
  2. Install Debian into it. Name the machine 'vastra', create 2 accounts, root and vagrant. Use this as a proxy: http://192.168.1.2:8000/ Install only the ssh server and the system utilities here.
  3. Boot the machine
  4. I am only running the machine from vagrant (ssh) I don't need the guest additions. Bypass those instructions.
  5. Ignore the instructions about setting root password, this is Debian and you did that already.
  6. You do need to set up sudo. This works- log in as root--
apt-get install sudo
echo "vagrant ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/vagrant
  1. Since we just installed from the 'net there is no reason to update/upgrade now. You can if you want.
  2. Log out from the virtualbox console and log in via ssh as user vagrant so you can paste this:
mkdir -p /home/vagrant/.ssh
chmod 0700 /home/vagrant/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh
  1. You already installed the SSH server but still need to edit config. I do it like this
sudo -s
echo "AuthorizedKeysFile %h/.ssh/authorized_keys" >> /etc/ssh/sshd_config
  1. Zero out the box and shut it down
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
poweroff
  1. Package it!
cd ~/Projects/vastra-box
vagrant package --base vastra-4gb

Vastra development machine

I need to be able to run a test machine on the Mac so that I can go offline in Gold Beach. And maybe so that I don't mess up our phones every time I get crazy testing.

cd ~/Projects
mkdir vastra-debian
cd vastra-debian
vagrant init deb/jessie-amd64
vagrant up --provider virtualbox
vagrant ssh

I also need to be able to simulate a target machine, one stripped down to the minimal requirements to run Vastra.

cd ~/Projects
mkdir vastra-target
cd vastra-target
vagrant init deb/jessie-amd64
vagrant up --provider virtualbox
vagrant ssh