Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Oracle Linux Cookbook

You're reading from   Oracle Linux Cookbook Embrace Oracle Linux and master Linux Server Management

Arrow left icon
Product type Paperback
Published in Jan 2024
Publisher Packt
ISBN-13 9781803249285
Length 548 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Erik Benner Erik Benner
Author Profile Icon Erik Benner
Erik Benner
Mr. Jonathan Spindel Mr. Jonathan Spindel
Author Profile Icon Mr. Jonathan Spindel
Mr. Jonathan Spindel
Erik B. Thomsen Erik B. Thomsen
Author Profile Icon Erik B. Thomsen
Erik B. Thomsen
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Chapter 1: Oracle Linux 8 – Get It? Got It? Good! 2. Chapter 2: Installing with and without Automation Magic FREE CHAPTER 3. Chapter 3: Exploring the Various Boot Options and Kernels in Oracle Linux 4. Chapter 4: Creating and Managing Single-Instance Filesystems 5. Chapter 5: Software Management with DNF 6. Chapter 6: Eliminating All the SPOFs! An Exercise in Redundancy 7. Chapter 7: Oracle Linux 8 – Patching Doesn’t Have to Mean Rebooting 8. Chapter 8: DevOps Automation Tools – Terraform, Ansible, Packer, and More 9. Chapter 9: Keeping the Data Safe – Securing a System 10. Chapter 10: Revisiting Modules and AppStreams 11. Chapter 11: Lions, Tigers, and Containers – Oh My! Podman and Friends 12. Chapter 12: Navigating Ansible Waters 13. Chapter 13: Let’s All Go to the Cloud 14. Index 15. Other Books You May Enjoy

Automating the OS install options with kickstart

The kickstart file is one of the most important parts of the automated install process. This file contains all the information required to automatically install and configure the OS. The kickstart file is a simple text file that contains the directions to allow an unattended installation.

Getting ready

In order to work with kickstart files, you will need somewhere to build the system, such as Oracle VM VirtualBox. This system can be used to create your first kickstart file, as well as testing new kickstart files before moving them into the PXE environment.

Note

Anaconda is the Oracle Linux installer. It can operate via an automated install using a kickstart file, or interactively via a graphic or text install interface.

How to do it…

While you can manually create a file from scratch, it is much easier to start with the file that Anaconda creates on installation. This kickstart file is created automatically when a manual is installed and saved on the new system in /root/anaconda-ks.cfg. This file can be easily edited and reused for future builds. Let’s look at the file by breaking it down into smaller sections. This system is a graphical installation. Other options are text or cmdline:

Note

There are many options for kickstart, and they are listed in Appendix – kickstart options.

#version=OL8
# Use graphical install
graphical

The repo used to install Oracle Linux was a directory that was loopback mounted from an ISO file. baseurl can also be an HTTPS server, an NFS location, or an FTP server. For example, --baseurl=https://pxe.m57.local/ol8 will tell kickstart to pull the RPMs from a web server:

repo --name="AppStream" --baseurl=file:///run/install/sources/mount-0000-cdrom/AppStream

The packages are the software packages selected. Names starting with an @ sign are package groups, and lines without @ are individual packages. Also, the ^ symbol is used to enable the installation of only the required packages in a group. If ^ is not set, all packages in the group are installed. In this example, the graphical-server-environment package group RPMs are installed as well as the kexec-tools package:

%packages
@^graphical-server-environment
kexec-tools
%end

This is where the default keyboard and language are selected:

# Keyboard layouts
keyboard --xlayouts='us'
# System language
lang en_US.UTF-8

This is the hostname for the new server. Ideally, it should be the Fully Qualified Domain Name (FQDN) for the system:

# Network information
network  --hostname=ol802.lab.m57.local

This is used to select a CD-ROM or a CD-ROM mounted on a filesystem as the installation media:

# Use CDROM installation media
cdrom

This is used to run the setup agent on the first boot:

# Run the Setup Agent on first boot
firstboot --enable

Here, the install disk is selected, as well as the configuration of the logical volume manager and filesystems:

ignoredisk --only-use=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part pv.116 --fstype="lvmpv" --ondisk=sda --size=80868
volgroup ol --pesize=4096 pv.116
logvol /home --fstype="xfs" --size=5120 --name=home --vgname=ol
logvol / --fstype="xfs" --size=51200 --name=root --vgname=ol
logvol /u01 --fstype="xfs" --size=10240 --name=u01 --vgname=ol
logvol /var --fstype="xfs" --size=5120 --name=var --vgname=ol
logvol swap --fstype="swap" --size=4056 --name=swap --vgname=ol
logvol /var/log --fstype="xfs" --size=5120 --name=var_log --vgname=ol

This is the time zone for the server:

# System timezone
timezone America/New_York --isUtc

An encrypted root password can be set on the new system. Normally, the password is encrypted, but optionally, you can use the –-plaintext option with a plaintext password. You can also generate an encrypted password using the python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())' Python command:

# Root password
rootpw --iscrypted $6$W5fC.GDUSIVXPDS7$zQFm49tGCtRbfyAd/0f57QcuPZYtOB/gobgN2oKNG
zqrseiNtm7QqkthCcdiNxGJhzLSIQpNyxRQXEPJPuaYM.

This enables kdump, allowing the kernel to save a crash dump to a device for troubleshooting:

%addon com_redhat_kdump --enable --reserve-mb='auto'
%end

This is the password policy for root, users, and Linux Unified Key Setup (LUKS) passphrases:

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

You can edit the file as needed. Before using a new file, it can be tested with the ksvalidator command. This command is part of the pykickstart package, installed via dnf install -y pykickstart.

Once the package is installed, test a new kickstart file by running ksvalidator $FILE. A sample with an error will look like the following, where line 3 defines the install as xgraphical, which is an unknown option:

[root@localhost ~]# ksvalidator anaconda-ks.cfg
The following problem occurred on line 3 of the kickstart file:
Unknown command: xgraphical

Resolve the error and rerun the validation. In this example, graphical is the correct parameter to use. A clean validation returns nothing and will look as follows:

Figure 2.2 – Clean ksvalidator

Figure 2.2 – Clean ksvalidator

Kickstart options!

Now that you have a basic understanding of the kickstart file, you can start adding new options. These options allow you to automate the installation and also grant you more control. The options are covered in Appendix – kickstart options.

How it works…

You can boot any system with kickstart manually by adding the ks parameter to the GRand Unified Bootloader (GRUB) entry. The format is ks=PATH_TO_FILE, where PATH_TO_FILE is a URL where the kickstart file can be read from. This is usually placed on an HTTP server that is accessible to clients.

You have been reading a chapter from
Oracle Linux Cookbook
Published in: Jan 2024
Publisher: Packt
ISBN-13: 9781803249285
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image