Vagrant: Difference between revisions
Brian Wilson (talk | contribs) |
Brian Wilson (talk | contribs) |
||
Line 40: | Line 40: | ||
Refinement: Make the virtual hard drive smaller, there is no earthly reason for it to be 40GB. | Refinement: Make the virtual hard drive smaller, there is no earthly reason for it to be 40GB. | ||
The default 8GB is big enough | The default 8GB is big enough. | ||
Quick version | Quick version | ||
'''Build a virtualbox.''' Use | '''Build a virtualbox.''' Use 8GB VMDK drive. Turn off audio and USB, put the network interface in bridged mode so it gets a real IP. | ||
'''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. | '''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. | ||
Line 52: | Line 52: | ||
* Ignore the instructions about setting root password, this is Debian and you did that already. | * Ignore the instructions about setting root password, this is Debian and you did that already. | ||
I do need to set up sudo. This works- log in as root-- | |||
apt-get install sudo | apt-get install sudo | ||
echo "vagrant ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/vagrant | echo "vagrant ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/vagrant | ||
I want it to use a proxy for all downloads, | I want it to use a proxy for all downloads, hence: | ||
apt-get install squid-deb-proxy-client | apt-get install squid-deb-proxy-client | ||
* Since we just installed from the 'net there is no reason to update/upgrade now | * Since we just installed from the 'net there is no reason to update/upgrade now. | ||
'''Set up keys.''' Log out from the virtualbox console and log in via ssh as user vagrant so you can paste this: | '''Set up keys.''' Log out from the virtualbox console and log in via ssh as user vagrant so you can paste this: | ||
Line 68: | Line 68: | ||
chown -R vagrant /home/vagrant/.ssh | chown -R vagrant /home/vagrant/.ssh | ||
Already installed the SSH server but still need to edit config. I do it like this | |||
sudo -s | sudo -s | ||
echo "AuthorizedKeysFile %h/.ssh/authorized_keys" >> /etc/ssh/sshd_config | echo "AuthorizedKeysFile %h/.ssh/authorized_keys" >> /etc/ssh/sshd_config | ||
Line 79: | Line 79: | ||
'''Package it!''' | '''Package it!''' | ||
cd ~/Projects/vastra-box | cd ~/Projects/vastra-box | ||
vagrant package --base vastra- | vagrant package --base vastra-8gb | ||
mv package.box vastra- | mv package.box vastra-8gb.box | ||
'''Add it to your inventory''' | '''Add it to your inventory''' | ||
vagrant box add vastra- | vagrant box add vastra-8gb vastra-8gb.box | ||
'''Test it!''' | '''Test it!''' | ||
vagrant init vastra- | vagrant init vastra-8gb | ||
cp ../vastra-ansible/Vagrantfile . | cp ../vastra-ansible/Vagrantfile . | ||
# Adjust settings as needed, will this be a pbx or dev machine? | # Adjust settings as needed, will this be a pbx or dev machine? |
Revision as of 05:29, 7 February 2016
"Vagrant" is a system for managing virtual machines.
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
Using a generic Debian box
mkdir generic cd generic vagrant init debian/jessie64; vagrant up --provider virtualbox vagrant up
Keeping guest additions up to date
Install this plugin: https://github.com/dotless-de/vagrant-vbguest
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.
Quick version
Build a virtualbox. Use 8GB VMDK drive. Turn off audio and USB, put the network interface in bridged mode so it gets a real IP.
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.
Boot the machine and set it up.
- I am only running the machine from vagrant (ssh) I don't need the guest additions. Bypass those instructions.
- Ignore the instructions about setting root password, this is Debian and you did that already.
I 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
I want it to use a proxy for all downloads, hence:
apt-get install squid-deb-proxy-client
- Since we just installed from the 'net there is no reason to update/upgrade now.
Set up keys. 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
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
Zero out the box and shut it down
dd if=/dev/zero of=/EMPTY bs=1M rm -f /EMPTY poweroff
Package it!
cd ~/Projects/vastra-box vagrant package --base vastra-8gb mv package.box vastra-8gb.box
Add it to your inventory
vagrant box add vastra-8gb vastra-8gb.box
Test it!
vagrant init vastra-8gb cp ../vastra-ansible/Vagrantfile . # Adjust settings as needed, will this be a pbx or dev machine? emacs Vagrantfile # Deployment machines don't need this # but development machines do-- allows shared folders to work vagrant plugin install vagrant-vbguest vagrant up
This should bring the machine up and provision it to be a Vastra box all in one go.
Make a note to look at Packer to further automate this...
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 vastra-4gb cp ../vastra-ansible/Vagrantfile . # Select dev options emacs Vagrantfile # Allow shared src folder vagrant plugin install vagrant-vbguest vagrant up vagrant ssh
You can log into the Squid cache machine and tail its log to see that it is indeed caching package requests from the vm.
ssh bellman sudo tail -f /var/log/squid-deb-proxy/access.log
I also need to be able to simulate a target machine, one stripped down to the minimal requirements to run Vastra.
cd ~/Projects mkdir pbx cd pbx vagrant init vastra-4gb cp ../vastra-ansible/Vagrantfile . vagrant up vagrant ssh