Skip to content

Instantly share code, notes, and snippets.

@573
Forked from aweijnitz/Vagrantfile
Last active August 29, 2015 14:13
Show Gist options
  • Save 573/bcc633f152a18e79a8b6 to your computer and use it in GitHub Desktop.
Save 573/bcc633f152a18e79a8b6 to your computer and use it in GitHub Desktop.

Reused that box description for proof-of-concept jenkins-in-a-box for M$-bound developers.

The ssh-call to ssh into the once enrolled box was (information per vagrant ssh-config):

$ ssh [email protected] -p 2200 -i /d/tools/vagrant-aweijnitz/.vagrant/machines/default/virtualbox/private_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o IdentitiesOnly=yes -o LogLevel=FATAL

Have to look more deeply on the set of commands vagrant understands, not to forget one of them vagrant reload on changes in the configuration.

On some occasions ssh-add ~/.vagrant.d/insecure_private_key can be useful.

#!/bin/bash
if [ ! -f /usr/bin/svn ];
then
echo "-------- PROVISIONING SUBVERSION ------------"
echo "---------------------------------------------"
## Install subverison
apt-get update
apt-get -y install subversion
else
echo "CHECK - Subversion already installed"
fi
if [ ! -f /usr/lib/jvm/java-7-oracle/bin/java ];
then
echo "-------- PROVISIONING JAVA ------------"
echo "---------------------------------------"
## Make java install non-interactive
## See http://askubuntu.com/questions/190582/installing-java-automatically-with-silent-option
echo debconf shared/accepted-oracle-license-v1-1 select true | \
debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | \
debconf-set-selections
## Install java 1.7
## See http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get -y install oracle-java7-installer
else
echo "CHECK - Java already installed"
fi
if [ ! -f /etc/init.d/jenkins ];
then
echo "-------- PROVISIONING JENKINS ------------"
echo "------------------------------------------"
## Install Jenkins
#
# URL: http://localhost:6060
# Home: /var/lib/jenkins
# Start/Stop: /etc/init.d/jenkins
# Config: /etc/default/jenkins
# Jenkins log: /var/log/jenkins/jenkins.log
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
apt-get update
apt-get -y install jenkins
# Move Jenkins to port 6060
sed -i 's/8080/6060/g' /etc/default/jenkins
/etc/init.d/jenkins restart
else
echo "CHECK - Jenkins already installed"
fi
### Everything below this point is not stricly needed for Jenkins to work
###
#if [ ! -f /etc/init.d/tomcat7 ];
#then
# echo "-------- PROVISIONING TOMCAT ------------"
# echo "-----------------------------------------"
#
#
# ## Install Tomcat (port 8080)
# # This gives us something to deploy builds into
# # CATALINA_BASE=/var/lib/tomcat7
# # CATALINE_HOME=/usr/share/tomcat7
# export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
# apt-get -y install tomcat7
#
# # Work around a bug in the default tomcat start script
# sed -i 's/export JAVA_HOME/export JAVA_HOME=\"\/usr\/lib\/jvm\/java-7-oracle\"/g' /etc/init.d/tomcat7
# /etc/init.d/tomcat7 stop
# /etc/init.d/tomcat7 start
#else
# echo "CHECK - Tomcat already installed"
#fi
if [ ! -f /usr/local/lib/ant/apache-ant-1.9.4/bin/ant ];
then
echo "-------- PROVISIONING ANT ---------------"
echo "-----------------------------------------"
mkdir -p /usr/local/lib/ant
cd /usr/local/lib/ant
wget -q http://ftp.halifax.rwth-aachen.de/apache//ant/binaries/apache-ant-1.9.4-bin.tar.gz
tar xzf apache-ant-1.9.4-bin.tar.gz
rm apache-ant-1.9.4-bin.tar.gz
ln -s /usr/local/lib/ant/apache-ant-1.9.4/bin/ant /usr/local/bin/ant
echo "Ant installed"
else
echo "CHECK - Ant already installed"
fi
if [ ! -f /usr/local/lib/maven/apache-maven-3.2.2/bin/mvn ];
then
echo "-------- PROVISIONING MAVEN--------------"
echo "-----------------------------------------"
mkdir -p /usr/local/lib/maven
cd /usr/local/lib/maven
wget -q http://ftp.halifax.rwth-aachen.de/apache//maven/binaries/apache-maven-3.2.2-bin.tar.gz
tar xzf apache-maven-3.2.2-bin.tar.gz
rm apache-maven-3.2.2-bin.tar.gz
ln -s /usr/local/lib/ant/apache-maven-3.2.2/bin/mvn /usr/local/bin/mvn
echo "Maven installed"
else
echo "CHECK - Maven already installed"
fi
echo "-------- PROVISIONING DONE ------------"
echo "-- Jenkins: http://localhost:6060 "
echo "-- Tomcat7: http://localhost:7070 "
echo "---------------------------------------"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
# Named boxes, like this one, don't need a URL, since the are looked up
# in the "vagrant cloud" (https://vagrantcloud.com)
#~ as I have a virtualbox installation on a M$ machine not supporting 64bit guests or special virtualization features
config.vm.box = "chef/debian-7.4-i386"
# Publish guest port 6060 on host port 6060
config.vm.network "forwarded_port", guest: 6060, host: 6060
config.vm.network "forwarded_port", guest: 8080, host: 7070
config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode. Use for debugging
# vb.gui = true
# # Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
# Provision the box using a shell script
# This script is copied into the box and then run
config.vm.provision :shell, :privileged => true, :path => "provision.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment