summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Pearkes <jackpearkes@gmail.com>2015-04-15 16:09:08 -0700
committerJack Pearkes <jackpearkes@gmail.com>2015-04-15 16:11:25 -0700
commiteac1d1a6d1c638602dc696d4101c11a3f80cbc1e (patch)
tree54f558caadcc82978cd398bc59857f033e296a66
initial commit
-rw-r--r--http/preseed.cfg91
-rw-r--r--scripts/base.sh24
-rw-r--r--scripts/cleanup.sh17
-rw-r--r--scripts/dep.sh9
-rw-r--r--scripts/vagrant.sh13
-rw-r--r--scripts/virtualbox.sh13
-rw-r--r--scripts/vmware.sh21
-rw-r--r--scripts/zerodisk.sh10
-rw-r--r--template.json111
9 files changed, 309 insertions, 0 deletions
diff --git a/http/preseed.cfg b/http/preseed.cfg
new file mode 100644
index 0000000..5f5b9c3
--- /dev/null
+++ b/http/preseed.cfg
@@ -0,0 +1,91 @@
+## Options to set on the command line
+d-i debian-installer/locale string en_US.utf8
+d-i console-setup/ask_detect boolean false
+d-i console-setup/layout string USA
+
+#d-i netcfg/get_hostname string dummy
+d-i netcfg/get_hostname string unassigned-hostname
+d-i netcfg/get_domain string unassigned-domain
+
+# Continue without a default route
+# Not working , specify a dummy in the DHCP
+#d-i netcfg/no_default_route boolean
+
+d-i time/zone string UTC
+d-i clock-setup/utc-auto boolean true
+d-i clock-setup/utc boolean true
+
+d-i kbd-chooser/method select American English
+
+d-i netcfg/wireless_wep string
+
+d-i base-installer/kernel/override-image string linux-server
+#d-i base-installer/kernel/override-image string linux-image-2.6.32-21-generic
+
+# Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive
+d-i debconf debconf/frontend select Noninteractive
+
+d-i pkgsel/install-language-support boolean false
+tasksel tasksel/first multiselect standard, ubuntu-server
+
+#d-i partman-auto/method string regular
+d-i partman-auto/method string lvm
+#d-i partman-auto/purge_lvm_from_device boolean true
+
+d-i partman-lvm/confirm boolean true
+d-i partman-lvm/device_remove_lvm boolean true
+d-i partman-auto/choose_recipe select atomic
+
+d-i partman/confirm_write_new_label boolean true
+d-i partman/confirm_nooverwrite boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+
+#http://ubuntu-virginia.ubuntuforums.org/showthread.php?p=9626883
+#Message: "write the changes to disk and configure lvm preseed"
+#http://serverfault.com/questions/189328/ubuntu-kickstart-installation-using-lvm-waits-for-input
+#preseed partman-lvm/confirm_nooverwrite boolean true
+
+# Write the changes to disks and configure LVM?
+d-i partman-lvm/confirm boolean true
+d-i partman-lvm/confirm_nooverwrite boolean true
+d-i partman-auto-lvm/guided_size string max
+
+## Default user, we can get away with a recipe to change this
+d-i passwd/user-fullname string vagrant
+d-i passwd/username string vagrant
+d-i passwd/user-password password vagrant
+d-i passwd/user-password-again password vagrant
+d-i user-setup/encrypt-home boolean false
+d-i user-setup/allow-password-weak boolean true
+
+## minimum is puppet and ssh and ntp
+# Individual additional packages to install
+d-i pkgsel/include string openssh-server ntp
+
+# Whether to upgrade packages after debootstrap.
+# Allowed values: none, safe-upgrade, full-upgrade
+d-i pkgsel/upgrade select full-upgrade
+
+d-i grub-installer/only_debian boolean true
+d-i grub-installer/with_other_os boolean true
+d-i finish-install/reboot_in_progress note
+
+#For the update
+d-i pkgsel/update-policy select none
+
+# debconf-get-selections --install
+#Use mirror
+#d-i apt-setup/use_mirror boolean true
+#d-i mirror/country string manual
+#choose-mirror-bin mirror/protocol string http
+#choose-mirror-bin mirror/http/hostname string 192.168.4.150
+#choose-mirror-bin mirror/http/directory string /ubuntu
+#choose-mirror-bin mirror/suite select maverick
+#d-i debian-installer/allow_unauthenticated string true
+
+choose-mirror-bin mirror/http/proxy string
+
+d-i preseed/late_command string \
+ in-target sed -i 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD:ALL/g' /etc/sudoers
+
diff --git a/scripts/base.sh b/scripts/base.sh
new file mode 100644
index 0000000..d09645d
--- /dev/null
+++ b/scripts/base.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+perl -p -i -e 's#http://us.archive.ubuntu.com/ubuntu#http://mirror.rackspace.com/ubuntu#gi' /etc/apt/sources.list
+
+# Update the box
+apt-get -y update >/dev/null
+apt-get -y install facter linux-headers-$(uname -r) build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev curl unzip >/dev/null
+
+# Tweak sshd to prevent DNS resolution (speed up logins)
+echo 'UseDNS no' >> /etc/ssh/sshd_config
+
+# Remove 5s grub timeout to speed up booting
+cat <<EOF > /etc/default/grub
+# If you change this file, run 'update-grub' afterwards to update
+# /boot/grub/grub.cfg.
+
+GRUB_DEFAULT=0
+GRUB_TIMEOUT=0
+GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
+GRUB_CMDLINE_LINUX_DEFAULT="quiet"
+GRUB_CMDLINE_LINUX="debian-installer=en_US"
+EOF
+
+update-grub
diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh
new file mode 100644
index 0000000..ef0d3da
--- /dev/null
+++ b/scripts/cleanup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+chmod 440 /etc/sudoers.d/vagrant
+
+# Removing leftover leases and persistent rules
+echo "cleaning up dhcp leases"
+rm /var/lib/dhcp/*
+
+# Make sure Udev doesn't block our network
+echo "cleaning up udev rules"
+rm /etc/udev/rules.d/70-persistent-net.rules
+mkdir /etc/udev/rules.d/70-persistent-net.rules
+rm -rf /dev/.udev/
+rm /lib/udev/rules.d/75-persistent-net-generator.rules
+
+echo "Adding a 2 sec delay to the interface up, to make the dhclient happy"
+echo "pre-up sleep 2" >> /etc/network/interfaces
diff --git a/scripts/dep.sh b/scripts/dep.sh
new file mode 100644
index 0000000..b839353
--- /dev/null
+++ b/scripts/dep.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+#
+# Setup the the box. This runs as root
+
+apt-get -y update
+
+apt-get -y install curl
+
+# You can install anything you need here.
diff --git a/scripts/vagrant.sh b/scripts/vagrant.sh
new file mode 100644
index 0000000..7b2d1a0
--- /dev/null
+++ b/scripts/vagrant.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Vagrant specific
+date > /etc/vagrant_box_build_time
+
+# Installing vagrant keys
+mkdir -pm 700 /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
+
+# Customize the message of the day
+echo 'Development Environment' > /etc/motd
diff --git a/scripts/virtualbox.sh b/scripts/virtualbox.sh
new file mode 100644
index 0000000..1404aa7
--- /dev/null
+++ b/scripts/virtualbox.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Bail if we are not running inside VirtualBox.
+if [[ `facter virtual` != "virtualbox" ]]; then
+ exit 0
+fi
+
+mkdir -p /mnt/virtualbox
+mount -o loop /home/vagrant/VBoxGuest*.iso /mnt/virtualbox
+sh /mnt/virtualbox/VBoxLinuxAdditions.run
+ln -s /opt/VBoxGuestAdditions-*/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
+umount /mnt/virtualbox
+rm -rf /home/vagrant/VBoxGuest*.iso
diff --git a/scripts/vmware.sh b/scripts/vmware.sh
new file mode 100644
index 0000000..b77ff2e
--- /dev/null
+++ b/scripts/vmware.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Bail if we are not running inside VMWare.
+if [[ `facter virtual` != "vmware" ]]; then
+ exit 0
+fi
+
+# Install the VMWare Tools from a linux ISO.
+
+#wget http://192.168.0.185/linux.iso -P /tmp
+mkdir -p /mnt/vmware
+mount -o loop /home/vagrant/linux.iso /mnt/vmware
+
+cd /tmp
+tar xzf /mnt/vmware/VMwareTools-*.tar.gz
+
+umount /mnt/vmware
+rm -fr /home/vagrant/linux.iso
+
+/tmp/vmware-tools-distrib/vmware-install.pl -d
+rm -fr /tmp/vmware-tools-distrib
diff --git a/scripts/zerodisk.sh b/scripts/zerodisk.sh
new file mode 100644
index 0000000..35370d6
--- /dev/null
+++ b/scripts/zerodisk.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# Zero out the free space to save space in the final image:
+dd if=/dev/zero of=/EMPTY bs=1M
+rm -f /EMPTY
+
+# Sync to ensure that the delete completes before this moves on.
+sync
+sync
+sync
diff --git a/template.json b/template.json
new file mode 100644
index 0000000..eaa4332
--- /dev/null
+++ b/template.json
@@ -0,0 +1,111 @@
+{
+ "variables": {
+ "atlas_username": "{{env `ATLAS_USERNAME`}}",
+ "atlas_name": "{{env `ATLAS_NAME`}}",
+ "version": "0.0.1"
+ },
+ "provisioners": [
+ {
+ "type": "shell",
+ "scripts": [
+ "scripts/base.sh",
+ "scripts/virtualbox.sh",
+ "scripts/vmware.sh",
+ "scripts/vagrant.sh",
+ "scripts/dep.sh",
+ "scripts/cleanup.sh",
+ "scripts/zerodisk.sh"
+ ],
+ "override": {
+ "virtualbox-iso": {
+ "execute_command": "echo 'vagrant'|sudo -S bash '{{.Path}}'"
+ },
+ "vmware-iso": {
+ "execute_command": "echo 'vagrant'|sudo -S bash '{{.Path}}'"
+ }
+ }
+ }
+ ],
+ "builders": [
+ {
+ "type": "virtualbox-iso",
+ "boot_command": [
+ "<esc><esc><enter><wait>",
+ "/install/vmlinuz noapic preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
+ "hostname={{ .Name }} ",
+ "fb=false debconf/frontend=noninteractive ",
+ "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false ",
+ "initrd=/install/initrd.gz -- <enter>"
+ ],
+ "headless": true,
+ "boot_wait": "10s",
+ "disk_size": 20480,
+ "guest_os_type": "Ubuntu_64",
+ "http_directory": "http",
+ "iso_checksum": "af224223de99e2a730b67d7785b657f549be0d63221188e105445f75fb8305c9",
+ "iso_checksum_type": "sha256",
+ "iso_url": "http://releases.ubuntu.com/precise/ubuntu-12.04.5-server-amd64.iso",
+ "ssh_username": "vagrant",
+ "ssh_password": "vagrant",
+ "ssh_port": 22,
+ "ssh_wait_timeout": "10000s",
+ "shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'vagrant'|sudo -S bash 'shutdown.sh'",
+ "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
+ "virtualbox_version_file": ".vbox_version"
+ },
+ {
+ "type": "vmware-iso",
+ "boot_command": [
+ "<esc><esc><enter><wait>",
+ "/install/vmlinuz noapic preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
+ "hostname={{ .Name }} ",
+ "fb=false debconf/frontend=noninteractive ",
+ "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false ",
+ "initrd=/install/initrd.gz -- <enter>"
+ ],
+ "boot_wait": "10s",
+ "disk_size": 20480,
+ "guest_os_type": "Ubuntu-64",
+ "headless": true,
+ "http_directory": "http",
+ "iso_checksum": "af224223de99e2a730b67d7785b657f549be0d63221188e105445f75fb8305c9",
+ "iso_checksum_type": "sha256",
+ "iso_url": "http://releases.ubuntu.com/precise/ubuntu-12.04.5-server-amd64.iso",
+ "skip_compaction": true,
+ "ssh_username": "vagrant",
+ "ssh_password": "vagrant",
+ "ssh_port": 22,
+ "ssh_wait_timeout": "10000s",
+ "shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'vagrant'|sudo -S bash 'shutdown.sh'",
+ "tools_upload_flavor": "linux"
+ }
+ ],
+ "post-processors": [
+ {
+ "type": "vagrant"
+ },
+ {
+ "type": "atlas",
+ "only": ["vmware-iso"],
+ "artifact": "{{user `atlas_username`}}/{{user `atlas_name`}}",
+ "artifact_type": "vagrant.box",
+ "metadata": {
+ "provider": "vmware-desktop",
+ "version": "{{user `version`}}"
+ }
+ },
+ {
+ "type": "atlas",
+ "only": ["virtualbox-iso"],
+ "artifact": "{{user `atlas_username`}}/{{user `atlas_name`}}",
+ "artifact_type": "vagrant.box",
+ "metadata": {
+ "provider": "virtualbox",
+ "version": "{{user `version`}}"
+ }
+ }
+ ],
+ "push": {}
+}