Reader small image

You're reading from  Oracle Linux Cookbook

Product typeBook
Published inJan 2024
Reading LevelBeginner
PublisherPackt
ISBN-139781803249285
Edition1st Edition
Languages
Tools
Right arrow
Authors (3):
Erik Benner
Erik Benner
author image
Erik Benner

Erik Benner is the VP of Enterprise Transformation and an Oracle ACE director. He is an expert strategist for customers across the United States. His customer engagements range from enterprise cloud transformations to data center consolidation and modernization. He frequently presents at conferences such as Oracle CloudWorld, ASCEND, BLUEPRINT 4D, and FOSSY. Having worked with Oracle and Sun Systems since the mid-90s, Erik is well-versed in most of the core Oracle technologies, including Oracle Cloud, Oracle Linux, and Oracle Database. When not flying to far points of the country from the Metro Atlanta area, he enjoys spending time with his family at their observatory, where the telescopes outnumber the people.
Read more about Erik Benner

Erik B. Thomsen
Erik B. Thomsen
author image
Erik B. Thomsen

Erik B. Thomsen is a Principal Sales Consultant passionate about Linux, cloud-native technologies, and “Everything as Code.” He is an innovative strategist with extensive experience working in multiple facets of IT, including DevSecOps, product management for databases and Linux, and platform engineering, where he led the development of an enterprise Kubernetes container platform. He has many years of consulting experience working for numerous Fortune 500 companies. Often described as a “visionary” or “thought leader” by his peers, Erik leverages his expertise in technology with his creative development and automation skills to help customers design, deploy, and manage cutting-edge IT solutions.
Read more about Erik B. Thomsen

Jonathan Spindel
Jonathan Spindel
author image
Jonathan Spindel

Jonathan Spindel is a highly skilled and experienced technology leader and evangelist with a strong emphasis on Oracle ecosystems cloud infrastructure and automation. With over 23 years in the industry, he possesses a comprehensive understanding of managing, designing, and deploying multi-tenant enterprise systems and cloud solutions to address business needs and enhance operational processes. Jonathan excels in providing end-to-end management and technical turnkey cloud solutions that drive increased business productivity and reduce operational costs, ultimately delivering timely returns on investment. His hands-on approach and deep expertise in Oracle and mainstream infrastructure and cloud technologies enable him to optimize performance and streamline operations, while his proficiency in automation ensures efficient and error-free processes.
Read more about Jonathan Spindel

View More author details
Right arrow

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.

Previous PageNext Page
You have been reading a chapter from
Oracle Linux Cookbook
Published in: Jan 2024Publisher: PacktISBN-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.
undefined
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 $15.99/month. Cancel anytime

Authors (3)

author image
Erik Benner

Erik Benner is the VP of Enterprise Transformation and an Oracle ACE director. He is an expert strategist for customers across the United States. His customer engagements range from enterprise cloud transformations to data center consolidation and modernization. He frequently presents at conferences such as Oracle CloudWorld, ASCEND, BLUEPRINT 4D, and FOSSY. Having worked with Oracle and Sun Systems since the mid-90s, Erik is well-versed in most of the core Oracle technologies, including Oracle Cloud, Oracle Linux, and Oracle Database. When not flying to far points of the country from the Metro Atlanta area, he enjoys spending time with his family at their observatory, where the telescopes outnumber the people.
Read more about Erik Benner

author image
Erik B. Thomsen

Erik B. Thomsen is a Principal Sales Consultant passionate about Linux, cloud-native technologies, and “Everything as Code.” He is an innovative strategist with extensive experience working in multiple facets of IT, including DevSecOps, product management for databases and Linux, and platform engineering, where he led the development of an enterprise Kubernetes container platform. He has many years of consulting experience working for numerous Fortune 500 companies. Often described as a “visionary” or “thought leader” by his peers, Erik leverages his expertise in technology with his creative development and automation skills to help customers design, deploy, and manage cutting-edge IT solutions.
Read more about Erik B. Thomsen

author image
Jonathan Spindel

Jonathan Spindel is a highly skilled and experienced technology leader and evangelist with a strong emphasis on Oracle ecosystems cloud infrastructure and automation. With over 23 years in the industry, he possesses a comprehensive understanding of managing, designing, and deploying multi-tenant enterprise systems and cloud solutions to address business needs and enhance operational processes. Jonathan excels in providing end-to-end management and technical turnkey cloud solutions that drive increased business productivity and reduce operational costs, ultimately delivering timely returns on investment. His hands-on approach and deep expertise in Oracle and mainstream infrastructure and cloud technologies enable him to optimize performance and streamline operations, while his proficiency in automation ensures efficient and error-free processes.
Read more about Jonathan Spindel