Virtualbox provisioning using Vagrant

Server(virtualbox) provisioning using vagrant.

To start using Vagrant (on Debian) download and install vagrant and virtualbox

	$ sudo wget /home/guy/Downloads/
	$ sudo dpkg -i /home/guy/Downloads/vagrant_1.7.4_i686.deb
	$ sudo apt-get install linux-headers-$(uname -r) build-essential dkms virtualbox-4.3 vim

Setup and configure Vagrant

	$ mkdir vagranttest
	$ cd vagranttest
	$ vim Vagrantfile (see example)
	$ vim (see example)
	$ vagrant init hashicorp/precise32

Vagrantfile example:

	Vagrant.configure("2") do |config| = "hashicorp/precise32"
		config.vm.provision :shell, path: "" :forwarded_port, guest: 80, host: 4567
	end example:

	#!/usr/bin/env bash

	printf "\n\n\n Started server provisioning, please wait \n\n\n"
	sudo apt-get update

	#mysql uservars and install
	printf "\n\n\n Installing database \n\n\n"
	sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password somepass'
	sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password somepass'
	sudo apt-get -y install mysql-server-5.5 php5-mysqlnd
	sudo service mysqld restart

	#apache, php, git
	printf "\n\n\n Installing webserver \n\n\n"
	sudo apt-get -y install apache2 php5-common libapache2-mod-php5 php5-cli git
	sudo service apache2 restart
	#set apache dir to vagrant dir
	if ! [ -L /var/www ]; then
	  rm -rf /var/www
	  ln -fs /vagrant /var/www

	#editor(s) and security
	printf "\n\n\n Installing other packages \n\n\n"
	sudo apt-get -y install clamav clamav-freshclam vim

	#set repo 
	sudo apt-get -y install git
	sudo ssh-agent /bin/bash
	ssh-add /vagrant/id_rsa
	sudo echo -e "Host\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config  
	cd /vagrant
	sudo yes | git clone 

	sudo freshclam && clamscan /vagrant
	echo "\n\n\nProvisioning completed, have a nice day!\n\n\n"

Start machine/deployment

	$ vagrant up
	$ vagrant ssh

why-guy add:

Last Tweets: