No questions asked Ubuntu install

Fri 13 December 2013

Still in the process of correctly provisioning and configuring my Homelab and VPS with Ansible, I ended up having to often reinstall servers just to make sure my playbooks were still working after a lot of edit+deploy iterations. I was really tired of having to log into the VNC console of my VPS providers and manually run through the whole ISO setup.

So today I decided I would take a break from coding Ansible playbooks and try to automate the provisioning of these servers ALA Kickstart… The goal:

NO QUESTIONS ASKED

So after a couple of iterations (again!!!), here is my preseed.cfg tested on Ubuntu 12.04 LTS x86_64:

## Options to set on the command line
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
d-i keyboard-configuration/layoutcode string us
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain

## Network config
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_timeout string 60

## Kernel
d-i base-installer/kernel/override-image string linux-server

## Clock
d-i clock-setup/utc-auto boolean true
d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern
d-i clock-setup/ntp boolean true

## Mirrors
d-i mirror/country string US
d-i mirror/http/proxy string
d-i mirror/protocol string http
d-i mirror/http/mirror select us.archive.ubuntu.com

## Partitions
d-i partman-auto/method string lvm
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman/default_filesystem string ext4

d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_lvm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-lvm/confirm boolean true

d-i partman/choose_partition select finish
d-i partman/confirm_write_new_label boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-md/confirm_nooverwrite boolean true

## User accounts
d-i passwd/root-login boolean false
d-i passwd/user-fullname string ubuntu
d-i passwd/username string ubuntu
d-i passwd/user-uid string 1000
d-i passwd/user-password password change_me_please
d-i passwd/user-password-again password change_me_please
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false

## Packages to install
tasksel tasksel/first multiselect standard, ubuntu-server
d-i pkgsel/install-language-support boolean false
d-i pkgsel/include string openssh-server

## Install security updates automatically
d-i pkgsel/update-policy select unattended-upgrades

## Grub setup
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true

## Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

You can view the meaning of all these statements here.

Unfortunatly, this process still isn’t fully automated. Since the network setup only happens after some questions are asked (notably language and keyboard layout), we have to give some additionnal parameters to the boot prompt (After the CD boots, select the language then F6). The boot line should look like the following (all on one line):

url=http://webserver.domain/path/preseed.cfg \
debian-installer/locale=en_US \
console-setup/ask_detect=false \
console-setup/layoutcode=us \
keyboard-configuration/layoutcode=us \
netcfg/choose_interface=auto \
hostname=YOURHOSTNAME \
domain=YOURDOMAINE \
initrd=/install/initrd.gz quiet --

In my opinion, it’s still a lot better than having to go through the whole setup. Especially now that I can add some additionnal configuration (installed packages, user groups…) at provision time!

UPDATE 2013-12-15:

I had some problems with the previous boot line:

I solved this with some boot line aliases and other parameters:

url=http://webserver.domain/path/preseed.cfg \
auto=true priority=critical \
hostname=HOSTNAME domain=DOMAIN \
interface=auto \
initrd=/install/initrd.gz quiet --

UPDATE 2014-04-18:

While testing an automated installation of Ubuntu 14.04, I ran into some problems I didn’t encounter the first time. I was getting 2 more confirmation dialogs during the partitioning steps. I had to add the following properties to my preseed.cfg:

d-i partman/confirm_nooverwrite boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-md/confirm_nooverwrite boolean true

I updated the file content in the original post.