Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes... #1

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9c4ced8
Build the Ubuntu 10.10 Maverick vagrant box - minus the devstructure …
dreamcat4 Nov 8, 2010
27cd0a0
Add 'ruby' metapackage to base dependencies
dreamcat4 Nov 20, 2010
86d5b19
Shorten hostname
dreamcat4 Nov 20, 2010
3077759
Remove hdiutil call and use builtin mount commands. This should add
jasherai Nov 30, 2010
5490267
Remove devstructure branding on files.
jasherai Dec 1, 2010
7fa6793
Ensure private ssh key has correct permissions
jasherai Dec 1, 2010
03e55a1
Add an rvmrc to be able to use this with different versions of ruby
jasherai Dec 5, 2010
98c0b9a
Add a Gemfile and dep for vagrant gem so it is easy to ensure all deps
jasherai Dec 5, 2010
c81f88a
Add snapshot after initial install and after install of vagrant deps
jasherai Dec 5, 2010
2123f00
Merge branch 'feature/cleanups_and_fixes' into develop
jasherai Dec 5, 2010
38074b6
Remove the generated udev rule for net device before box generation so
jasherai Dec 5, 2010
7f3a34a
rename the "username" variable to user_name so it doesn't use the env…
jasherai Dec 15, 2010
d49da7f
Remove the persistent-net udev rule file before packaging the box. On
jasherai Dec 15, 2010
698da09
Fix order of deleting snapshots and also the name of the second snapshot
jasherai Dec 15, 2010
09c3ec5
Add support for hostiocache enabling on ext4 filesystems
jasherai Dec 15, 2010
f3ecd31
Upgrade vagrant to 0.7.1 for VirtualBox 4.0.2 support
jasherai Jan 31, 2011
0a0e0fd
Update memory requirement and VBoxManage commands to support VirtualB…
jasherai Jan 31, 2011
6b93946
Change snapshot names. The '#' may not be entirely safe and can't be
jasherai Jan 31, 2011
16ecbdd
Add support for nfs. nfs_compat var is filled with the name of
jasherai Jan 31, 2011
43ee284
Add support for apt proxy (apt-cacher-ng tested).
jasherai Jan 31, 2011
254f54d
Minor tweaks
jasherai Jan 31, 2011
c406c80
Remove the apt proxy setting before packaging the box.
jasherai Jan 31, 2011
d3a93ac
Add a script to build vbox and vagrant boxes from pxe and netboot
jasherai Mar 1, 2011
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ruby_ver=ruby-1.9.2
#gemset_name=vagrant
gemset_name=${gemset_name:-$(basename $(pwd))}


## The rest is auto...

rvm_install_on_use_flag=1 rvm --create use ${ruby_ver}@${gemset_name:-$(basename $(pwd))} > /dev/null
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# A sample Gemfile
source "http://rubygems.org"

# gem "rails"

gem "vagrant"
35 changes: 35 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
archive-tar-minitar (0.5.2)
erubis (2.6.6)
abstract (>= 1.0.0)
ffi (0.6.3)
rake (>= 0.8.7)
i18n (0.5.0)
json (1.4.6)
mario (0.0.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.1.0)
rake (0.8.7)
thor (0.14.6)
vagrant (0.7.1)
archive-tar-minitar (= 0.5.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
json (~> 1.4.6)
mario (~> 0.0.6)
net-scp (~> 1.0.4)
net-ssh (~> 2.1.0)
thor (~> 0.14.6)
virtualbox (~> 0.8.3)
virtualbox (0.8.3)
ffi (~> 0.6.3)

PLATFORMS
ruby

DEPENDENCIES
vagrant
32 changes: 19 additions & 13 deletions build-iso
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for ARCH in $ARCHS
do
ORIG="ubuntu-$VERSION-$DISTRO-$ARCH.iso"
COPY="ubuntu-$VERSION-$DISTRO-$ARCH"
ISO="devstructure-ubuntu-$VERSION-$DISTRO-$ARCH.iso"
ISO="${ISOPREFIX}-ubuntu-$VERSION-$DISTRO-$ARCH.iso"

# Download the original ISO if it isn't present already.
[ -f "$ORIG" ] || curl -L -o "$ORIG" \
Expand All @@ -19,13 +19,16 @@ do

# Make a writable copy of the original ISO. This uses the `hdiutil`
# command that is specific to Mac OS X.
hdiutil attach -mountpoint "mount" "$ORIG"
rsync -a "mount/" "$COPY"
hdiutil detach "mount"
mkdir -p isomount
sudo mount -o loop,user "${ORIG}" isomount
rsync -a "isomount/" "$COPY"
sudo umount isomount
chmod -R +w "$COPY"

# Customize the writable copy.
cp "isolinux.cfg" "$COPY/isolinux/"
m4 \
-D __LABEL__="${LABEL}" \
"isolinux.cfg.m4" > "$COPY/isolinux/isolinux.cfg"
m4 \
-D __HOST__="$HOST" \
-D __DOMAIN__="$DOMAIN" \
Expand All @@ -34,22 +37,25 @@ do
|| echo server
)" \
-D __ROOT_PASSWORD__="$ROOT_PASSWORD" \
-D __USERNAME__="$USERNAME" \
-D __USER_NAME__="$USER_NAME" \
-D __PASSWORD__="$PASSWORD" \
"devstructure.seed.m4" >"$COPY/preseed/devstructure.seed"
cp "$PUBLIC_KEY" "setup.sh" "$COPY/"
-D __LABEL__="${LABEL}" \
-D __NFS_COMPAT__="${NFS_COMPAT}" \
-D __PROXY_URL__="${PROXY_URL}" \
"default.seed.m4" >"$COPY/preseed/${LABEL}.seed"

# cp "$PUBLIC_KEY" "setup.sh" "$COPY/"
cp "$PUBLIC_KEY" "sudoers" "$COPY/"
m4 \
-D __USERNAME__="$USERNAME" \
-D __USER_NAME__="$USER_NAME" \
-D __PUBLIC_KEY__="$PUBLIC_KEY" \
"devstructure.sh.m4" >"$COPY/devstructure.sh"

"default.sh.m4" >"$COPY/${LABEL}.sh"
# Build a custom ISO.
mkisofs -r -V "Ubuntu $VERSION for DevStructure" \
mkisofs -r -V "Ubuntu $VERSION for ${LABEL}" \
-cache-inodes -J -l -no-emul-boot \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-boot-load-size 4 -boot-info-table \
-o "$ISO" "$COPY"

echo "Completed building custom iso for ${LABEL} [${ARCH}]"
done
78 changes: 78 additions & 0 deletions build-pxe
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/sh

# PXE BOOT [WVVVVMIP] (Work Very Very Very Very Much in Progress!)
# New script to take the iso image and use it and the parameters defined in the config.sh to setup and use pxe boot for setting up vagrant boxes
#

set -e

. "$(dirname $0)/config.sh"

[ ${VBOX_PXE_BUILD} -eq 1 ] || {
echo "PXE Building is DISABLED. Please enable in config.sh"
exit 2
}

for ARCH in $ARCHS
do
ORIG="ubuntu-$VERSION-$DISTRO-$ARCH.iso"
COPY="ubuntu-$VERSION-$DISTRO-$ARCH"
ISO="${ISOPREFIX}-ubuntu-$VERSION-$DISTRO-$ARCH.iso"
VBOX="${LABEL}-ubuntu-$VERSION-$DISTRO-$ARCH"
NETBOOT="ubuntu-$VERSION_NAME-$ARCH-netboot"
NETBOOT_FILE="${NETBOOT}.tar.gz"
NETBOOT_DIR="${VBOX_CONF_HOME}/ubuntu-$VERSION_NAME-netboot"
NETBOOT_URI="http://archive.ubuntu.com/ubuntu/dists/$VERSION_NAME/main/installer-$ARCH/current/images/netboot/netboot.tar.gz"
CURR_DIR=$(pwd)

# echo $NETBOOT_URI
# Download the original netboot files if it isn't present already.
# echo "${NETBOOT_DIR}"
[ -f "$NETBOOT_FILE" ] || {
curl -L -o "${NETBOOT_FILE}" "${NETBOOT_URI}"
}
[ -d ${NETBOOT_DIR} ] || mkdir -p ${NETBOOT_DIR}
[ -d ${PRESEED_PATH} ] || mkdir -p ${PRESEED_PATH}

(cd ${NETBOOT_DIR} && tar xzf ${CURR_DIR}/${NETBOOT}.tar.gz)
# Make a e copy of the original ISO. This uses the `hdiutil`
# command that is specific to Mac OS X.

# Customize the writable copy.
mv "${NETBOOT_DIR}/ubuntu-installer/${ARCH}/boot-screens/syslinux.cfg" "${NETBOOT_DIR}/ubuntu-installer/${ARCH}/boot-screens/syslinux.cfg_ORIG"
m4 \
-D __LABEL__="${LABEL}" \
-D __ARCH__="$ARCH" \
-D __HOST__="$HOST" \
-D __PRESEED_URI__="${PRESEED_HOST}/${LABEL}.seed" \
"pxelinux.cfg.m4" > "${NETBOOT_DIR}/ubuntu-installer/${ARCH}/boot-screens/syslinux.cfg"
ln -nfs ${NETBOOT_DIR}/pxelinux.0 ${NETBOOT_DIR}/${VBOX}.pxe
m4 \
-D __HOST__="$HOST" \
-D __DOMAIN__="$DOMAIN" \
-D __KERNEL__="linux-$([ "$ARCH" = "i386" ] \
&& echo generic-pae \
|| echo server
)" \
-D __ROOT_PASSWORD__="$ROOT_PASSWORD" \
-D __USER_NAME__="$USER_NAME" \
-D __PASSWORD__="$PASSWORD" \
-D __LABEL__="${LABEL}" \
-D __NFS_COMPAT__="${NFS_COMPAT}" \
-D __VERSION_NAME__="${VERSION_NAME}" \
-D __PROXY_URL__="${PROXY_URL}" \
-D __LOCALE__="en_US" \
-D __PRESEED_HOST__="${PRESEED_HOST}" \
"pxe.seed.m4" >"${PRESEED_PATH}/${LABEL}.seed"

# cp "$PUBLIC_KEY" "setup.sh" "$COPY/"
cp "$PUBLIC_KEY" "sudoers" "${NETBOOT_DIR}/"
tar -czf ${PRESEED_PATH}/setup.tgz "${PUBLIC_KEY}" "sudoers"
m4 \
-D __LABEL__="$LABEL" \
-D __PRESEED_HOST__="$PRESEED_HOST" \
-D __USER_NAME__="$USER_NAME" \
-D __PUBLIC_KEY__="$PUBLIC_KEY" \
"perm_setup.sh.m4" >"${PRESEED_PATH}/${LABEL}.sh"
echo "** Completed building custom pxe for ${LABEL} [${ARCH}]"
done
43 changes: 38 additions & 5 deletions build-vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ set -e

for ARCH in $ARCHS
do
VBOX="devstructure-ubuntu-$VERSION-$DISTRO-$ARCH"
VBOX="${LABEL}-ubuntu-$VERSION-$DISTRO-$ARCH"

# Reset to snapshot at time of initial build
VBoxManage snapshot "${VBOX}" restore "AUTO_${LABEL}_base_build__000001"

# Start the virtual machine. Spin slowly until SSH is usable.
VBoxManage startvm "$VBOX" --type gui
Expand All @@ -19,24 +22,54 @@ do
# Install Ruby, RubyGems, and Chef as Vagrant requires.
eval "$SSH \"
set -e
sudo apt-get -y install build-essential ruby-dev rubygems
export DEBCONF_FRONTEND=noninteractive
sudo -E apt-get -y install build-essential ruby ruby-dev rubygems
sudo gem install --no-rdoc --no-ri chef
echo 'PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/gems/1.8/bin\"' | sudo tee /etc/environment >/dev/null
\""

# Remove generated udev rule for network device as the mac address on the next instantiation is not going to match
eval "$SSH \"
sudo rm /etc/udev/rules.d/70-persistent-net.rules
\""
# Shutdown the virtual machine.
eval "$SSH \"sudo shutdown -h now\""
until VBoxManage showvminfo "$VBOX" | grep "^State: *powered off"
do
sleep 1
done

## Check if vagrant box dir for vagrant drives is hosted on an ext4 fs. If so, ensure hostiocache is enabled to avoid corruption
[ ${HOSTIOCACHE} ] || {
vbox_hd_dir="$HOME/.vagrant/boxes"
HOSTIOCACHE="";
for dir in ${vbox_hd_dir}; do
vbox_hd_dir_disk=$(df ${dir} | tail -n 1 | cut -d" " -f1);
vbox_hd_dir_fs="$(grep ${vbox_hd_dir_disk} /proc/mounts | awk '{ print $3 }')"
[ "$vbox_hd_dir_fs" = "ext4" ] && {
echo "Auto enabling HOSTIOCACHE due ext4 fs [${dir}]";
HOSTIOCACHE=" --hostiocache on ";
VBoxManage storagectl "$VBOX" \
--name SATA ${HOSTIOCACHE} \
break;
}
done
}

# Remove the Proxy configuration before packaging a box. Not all vagrant users will be running an apt proxy server on their machines.
[ ${BOX_DISABLE_APT_PROXY} -eq 1 ] && {
eval "$SSH \"
sudo sed -i '/^Acquire::http::Proxy/ d' /etc/apt/apt.conf
\""
}

# Now build the Vagrant box file.
vagrant package --base "$VBOX"
mv "package.box" \
"devstructure$([ "$ARCH" = "i386" ] && echo 32 || echo 64).box"
"${LABEL}$([ "$ARCH" = "i386" ] && echo 32 || echo 64).box"

# Snapshot after vagrant dep install....
VBoxManage snapshot "${VBOX}" take "AUTO_${LABEL}_vagrant_base__000002" --description "Snapshot taken after installing vagrant dependencies"
done

# Creating Vagrant boxes ruins the normal VM setup so get rid of them.
eval "$(dirname $0)/clean-vbox"
#eval "$(dirname $0)/clean-vbox"
Loading