Skip to content

Instantly share code, notes, and snippets.

@EntropyWorks
Created June 19, 2012 21:38
Show Gist options
  • Save EntropyWorks/2956691 to your computer and use it in GitHub Desktop.
Save EntropyWorks/2956691 to your computer and use it in GitHub Desktop.
12.04 TLS preseed.cfg and ipxe file for network install
!ipxe
set ipxe-ip 10.X.Y.Z
set base-url http://${ipxe-ip}
set preseed http://${ipxe-ip}
set http-proxy http://${ipxe-ip}:3142
set nic eth2
set use-cached 1
dhcp net1
echo mac...............: ${net1/mac}
echo ip................: ${ip}
echo netmask...........: ${netmask}
echo gateway...........: ${gateway}
echo dns...............: ${dns}
echo domain............: ${domain}
echo dhcp-server.......: ${dhcp-server}
echo filename..........: ${filename}
echo next-server.......: ${next-server}
echo uuid..............: ${uuid}
echo serial............: ${serial}
echo hostname..........: ${hostname}
echo syslog............: ${syslog}
echo .
kernel ${base-url}/linux
initrd ${base-url}/initrd-mlx4.gz
imgargs linux auto=true url=${preseed} http_proxy=${http-proxy} interface=${nic} hostname=REMOVED-${serial} domain=${domain} DEBCONF_INTERFACE=noninteractive
boot
|| shell
#!/bin/bash
#
# These commands should be run in the chroot of /target
export http_proxy="http://web-proxy.example.org:8080"
echo "export http_proxy=\"http://web-proxy.example.org:8080\"" >> /etc/profile.d/http_proxy.sh
export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Dirty fix to get lowercase hostname from the uppercase serial number
tr '[:upper:]' '[:lower:]' < /etc/hosts > /tmp/hosts
cat /tmp/hosts > /etc/hosts
# Trying to keek the host name lowercase
tr '[:upper:]' '[:lower:]' < /etc/hostname > /tmp/hostname
serial_number=$(cat /tmp/hostname | awk -F- '{print $NF}')
new_hostname=$(grep ${serial_number} /machine-list.csv |awk -F, '{print $1}' | tr -d '\"')
echo "127.0.0.1 localhost" > /etc/hosts
echo "127.0.1.1 ${new_hostname}.example.com ${new_hostname} ${serial_number}" >> /etc/hosts
echo "" >> /etc/hosts
echo "# The following lines are desirable for IPv6 capable hosts" >> /etc/hosts
echo "::1 ip6-localhost ip6-loopback" >> /etc/hosts
echo "fe00::0 ip6-localnet" >> /etc/hosts
echo "ff00::0 ip6-mcastprefix" >> /etc/hosts
echo "ff02::1 ip6-allnodes" >> /etc/hosts
echo "ff02::2 ip6-allrouters" >> /etc/hosts
echo ${new_hostname} > /etc/hostname
hostname -F /etc/hostname
if [ ! -f /paas-ipxe ] ; then
if [ -f /etc/modules ] ; then
echo "Adding modules to get networking to work"
echo "# Adding modules to get networking to work" >> /etc/modules
echo "8021q" >> /etc/modules
echo "mlx4_en" >> /etc/modules
fi
if [ -d /etc/sudoers.d ] ; then
# Adding to the suders
cat << EOF > /etc/sudoers.d/ubuntu-no-password
Defaults env_keep = "http_proxy ftp_proxy"
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
fred ALL=(ALL:ALL) NOPASSWD: ALL
EOF
# Changer Permissions
chmod 0440 /etc/sudoers.d/ubuntu-no-password
fi
if [ ! -d /etc/chef ] ; then
update-alternatives --remove-all gem
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 600 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/gem gem /usr/bin/gem1.9.1 \
--slave /var/lib/gems/bin gem-bin /var/lib/gems/1.9.1/bin
gem update --no-rdoc --no-ri
gem install ohai --no-rdoc --no-ri --verbose
gem install chef --no-rdoc --no-ri --verbose
mkdir -p /etc/chef
wget --no-proxy http://10.X.Y.Z/chef-client.tar.gz -O /etc/chef-client.tar.gz
cd /etc
tar zxvfp chef-client.tar.gz
chmod 0600 /etc/chef/validation.pem
fi
# Just adding the system to chef but not configuring anything else yet
if [ -f /usr/local/bin/chef-client ] ; then
/usr/local/bin/chef-client
fi
echo $(date) > /paas-ipxe
fi
web-001 ser001n
web-002 ser002n
web-003 ser005n
api-001 ser006n
d-i debian-installer/framebuffer boolean false
d-i debconf/language string en_US:en
d-i debian-installer/country string US
d-i debian-installer/language string en_US:en
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/preferred-locale string en_US.UTF-8
d-i localechooser/supported-locales en_US.UTF-8
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i time/zone string UTC
d-i clock-setup/utc boolean true
d-i netcfg/choose_interface select auto
d-i hw-detect/load_firmware boolean true
d-i hw-detect/select_modules multiselect mlx4_en 8021q
d-i passwd/root-login boolean false
d-i passwd/user-fullname string Fred Example
d-i passwd/username string fred
d-i passwd/user-default-groups string audio cdrom video admin sudo adm tty backup plugdev users
d-i passwd/user-password-crypted password <REMOVED>
d-i user-setup/encrypt-home boolean false
d-i mirror/protocol string http
d-i mirror/country string manual
d-i mirror/http/hostname string us.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string http://10.X.Y.Z:3142/
d-i mirror/suite string precise
d-i mirror/udeb/suite string precise
d-i mirror/udeb/components multiselect main, restricted
d-i base-installer/kernel/image string linux-server
d-i base-installer/kernel/override-image string linux-server
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto/expert_recipe string \
boot-root :: \
500 300 500 ext4 \
$primary{ } \
$bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
options/relatime{ relatime } \
. \
100 100000 1048576000 lvm \
$primary{ } \
$defaultignore{ } \
method{ lvm } \
device{ /dev/sda } \
vg_name{ system } \
. \
30720 100 61440 ext4 method{ lvm } \
$lvmok{ } mountpoint{ / } lv_name{ root } in_vg{ system } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
. \
1024 95 300% linux-swap method{ swap } \
format{ } $lvmok{ } lv_name{ swap } in_vg{ system } \
. \
20480 90 20480 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /var } lv_name{ var } in_vg{ system } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
. \
2048 85 10240 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /tmp } lv_name{ tmp } in_vg{ system } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
options/nodev{ nodev } options/nosuid{ nosuid } \
. \
20480 80 20480 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /home } lv_name{ home } in_vg{ system } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
options/nodev{ nodev } options/nosuid{ nosuid } \
. \
20480 75 20480 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /srv } lv_name{ srv } in_vg{ system } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
. \
1 1 1000000000 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /opt } lv_name{ opt } in_vg{ system } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
.
d-i partman-lvm/confirm_nochanges boolean false
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
tasksel tasksel/first multiselect openssh-server
d-i pkgsel/include string build-essential ntp wget rsync vlan bridge-utils debconf-utils ruby1.9.1-full ruby1.9.1-dev libruby1.9.1 ri1.9.1 rubygems
d-i pkgsel/upgrade string full-upgrade
d-i pkgsel/update-policy string unattended-upgrades
d-i pkgsel/install-language-support boolean true
d-i pkgsel/updatedb boolean true
popularity-contest popularity-contest/participate boolean false
ssh ssh/new_config boolean true
ssh ssh/protocol2_only boolean true
ssh ssh/run_sshd boolean true
ssh ssh/SUID_client boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
d-i cdrom-detect/eject boolean true
d-i finish-install/reboot_in_progress note
d-i debian-installer/main-menu select Finish the installation
d-i di-utils-reboot/really_reboot boolean true
d-i preseed/late_command string \
in-target /usr/bin/wget --no-proxy http://10.X.Y.Z/d-i/precise/late_command.sh ; \
in-target /bin/chmod +x /late_command.sh ; \
in-target /late_command.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment