How to automate Fedora install by kickstarting from netinstall image

Wow, that’s quite a title.  But I was unable to find a lot of helpful information on the internet describing how to accomplish what I aim to do.  I found a lot of hints and clues, but nothing that spelled it all out.  This page will capture my experience.

If you do not care to read (or about) all the words and explanations, feel free to skip to the SHORT VERSION

BACKGROUND

I use Fedora on my personal laptop. There are a lot of reasons for this which I won’t get into here, but the regular schedule of new releases provides me the “opportunity” to tweak my installation process. I can find various and distributed notes I’ve left myself and I have even often tried to script/automate it as much as possible, yet I tend to move on and abandon every attempt. (I even found a previous, unpublished page explicitly stating that I gave up)

So I was at Fedora’s booth at Red Hat Summit this year and asked a guy for some advice or insight on how to automate this whole song-and-dance that I find myself in routinely. He confirmed what I had found, that the LiveCD I had been trying to use to Kickstart a system would not work. He said that he always installs manually, but just uses the Minimal install and then configures his system with Ansible. I’m intrigued by this and will be attempting the same.

But that is not what this page is about. The kind gentleman also mentioned that, if I was determined to install via Kickstart (and I am…because I do this at work all the time, I should be able to figure it out here), then I would need to use the Netinstall Image. I had already learned this, but had always been unable to put all the pieces together. Now I have and it is actually very simple:

01 Download the correct image

There are tons of download options on getfedora.org, but once you’ve decided what spin and what “flavor” of system you’ll be installing on, it is important to grab the Netinstall Image (as opposed the Live Image):netinstall.image

NOTE: I will be installing the Workstation “flavor” and I have chosen to give Gnome a chance again, it is the default spin (I have other notes on some expeditions into other spins, but that is also for a different page)

02 Acquire a Kickstart file

There are probably places to get the default kickstart file and I have just as easily created my own based on experience and documentation, but I decided to build a test VM manually and then use the file it generated as a base.  Every time Fedora installs, it creates an anaconda-ks.cfg file in root’s home directory.  So I built a system only specifying a few things during the graphical installation:

  • hostname
  • root password
  • install the “ansible-node” group (since I’m preparing to configure w/ ansible)

I then copied this anaconda-ks.cfg file somewhere locally where I could modify it.

03 Modify the kickstart file

Now that I have a pretty default and vanilla kickstart file, I made the following modifications:
Point to a source:

In order to get the packages, you have to tell the kickstart where the packages reside.  This is the part that I was always missing.  I added the following lines near the top of my kickstart file:

# use a fedora mirror
url --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
Disable firstboot:

I changed the firstboot line as seen below, but the system always seems to come up asking me about languages and users and stuff…maybe I need to add these details to my kickstart file, but also maybe that firstboot screen will be skipped if I use Ansible to configure these types of things and reboot?:

# Don't run the Setup Agent on first boot
firstboot --disabled
Enable SSHD:

I’m not sure why this isn’t the default behavior, but I have to explicitly state that sshd should be started by adding it to the services line:

# System services
services --enabled="chronyd,sshd"

04 Make the kickstart file network accessible

I renamed the kickstart file something more appropriate and placed it in a location that was network accessible.  There are a number of options here but I chose to
place it somewhere on my private network that was being shared via http.  I had a few options on my private network, but I used it as a good opportunity to explore setting up an nginx container!

05 Boot to the ISO and specify the kickstart file

When you boot to the NetInstall Image ISO, instead of hitting “Enter” after highlighting “Install Fedora yadda yadda,” hit the “Tab” key with that line highlighted and specify the location of the kickstart with ks=:

ks.boot.line

There are a lot of options which are thoroughly documented, this is simply what I did.


NEXT STEPS

If all goes as planned (and depending on your network speed), you will have a newly installed and pretty minimal system after a little while!  It is repeatable now too, so if you need practice with Ansible, standardizing this basic build should be helpful (I explored Vagrant but wanted to get something going for myself).

WHAT I LEARNED

  • I searched high and low for the binary locations and finally found some hints in bugzilla but did not do a good job of making note of those

REFERENCES:


SHORT VERSION:

To avoid tl;dr enjoy this instead:

## 01 Download the correct image
#  be sure to download the NetInstall Image (NOT the Live Image)
## 02 Acquire a Kickstart file
#  make or find a general kickstart file for your flavor
## 03 Modify the kickstart file
#  MOST IMPORTANTLY, ADD THE SOURCE/URL:
url --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
#  disable firstboot
firstboot --disabled
#  enable SSHD in services
services --enabled="chronyd,sshd"
## 04 Make the kickstart file network accessible
## 05 Boot to the ISO and specify the kickstart file
#  get to the boot command prompt and use ks=

[return to top of page]

3 Comments for “How to automate Fedora install by kickstarting from netinstall image”

Leave a Reply

Your email address will not be published. Required fields are marked *