You might know this feature by other names like “unattended,” “hands-off,” or “preseeded” installation. But whatever you call it, the idea is simple: set up some configuration files and let Ubuntu do its thing without any human interaction required.
Now, before we dive into how to create these magical autoinstall configurations, why they’re so great. First of all, they save time. Imagine deploying dozens or even hundreds of new servers every week. With traditional manual installations, that would take forever and leave plenty of room for errors. But with autoinstalls, you can set up a configuration once and then let Ubuntu do the rest.
Secondly, they’re more reliable. When you have human beings involved in an installation process, there’s always the potential for mistakes or inconsistencies. With autoinstall, everything is scripted out and executed consistently every time. No more worrying about whether your new servers will be configured correctly!
So how do we create these magical configurations? Well, it’s actually pretty simple. First, you need to generate some configuration files that tell Ubuntu what to do during the installation process. These can include things like setting up a hostname, creating user accounts, and installing specific software packages. There are plenty of resources out there for learning how to create these configurations (like this awesome tutorial from Linux Tutorials), but we’ll cover some basics here.
First, the cloud-init file. This is a YAML configuration file that tells Ubuntu what to do during the installation process. Here’s an example:
#cloud-config
# This is a YAML configuration file that tells Ubuntu what to do during the installation process.
# Set the hostname for the server
hostname: myserver
# Create a user named "johndoe" with sudo privileges and add their public SSH key for remote access
users:
- name: johndoe
sudo: ['ALL=(ALL) NOPASSWD: ALL']
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDX1XIhfuJHl... (your public key here)
# The "users" section is a list, so each user is denoted by a "-" before their name
# The "sudo" line gives the user sudo privileges without requiring a password
# The "ssh_authorized_keys" line adds the user's public SSH key for remote access
In this example, we’re setting the hostname to “myserver” and creating a user account for johndoe with full sudo privileges. We’re also adding our SSH public key so that we can log in without having to enter a password every time.
Once you have your cloud-init file set up, you need to create an ISO image that includes this configuration and the Ubuntu installer. This is where covertsh’s autoinstall generator comes in handy (you can find it on GitHub). Here are some basic steps:
1. Download Ubuntu 20.04 from the official website.
2. Run `wget https://raw.githubusercontent.com/covertsh/ubuntu-autoinstall-generator/main/ubuntu-autoinstall-generator.sh` to download the autoinstall generator script.
3. Make sure you have xorriso, curl, and isolinux installed (you can do this with `sudo apt update && sudo apt install xorriso curl isolinux`).
4. Run `./ubuntu-autoinstall-generator.sh -c cloud-config.yaml -i ubuntu-20.04.iso -o autoinstall.iso`. This will generate an ISO image that includes your configuration and the Ubuntu installer.
5. Burn this ISO to a DVD or create a bootable USB drive using your preferred method (there are plenty of tutorials out there for doing this).
6. Boot from the new autoinstall media, and let Ubuntu do its thing!
And that’s it! With these simple steps, you can set up an entire fleet of servers without ever having to touch a keyboard or mouse. It’s like magic!