mariuszczyz.centos_pxe
CentOS 7/8 & Fedora PXE Boot Unattended OS Installation and Configuration Role
This guide explains how to set up a PXE boot environment for unattended installations of CentOS 7, CentOS 8, Fedora 31, and others with custom setups.
What It Does
This role installs and configures the following:
Installation ISOs & Local RPM Repository: If the installation files (ISOs) aren't on your machine, they'll be downloaded and mounted. Their content will create a local RPM repository for use during installation. This local repo can also be used later to install more packages.
TFTP Server & PXE: This allows network clients to boot using PXE.
Pre-configurations Included
The PXE service is set up to do the following:
- Boot from a local drive without installing anything
- Manually install Fedora 31 with a graphical interface
- Manually install CentOS 7 with a graphical interface
- Manually install CentOS 8 with a graphical interface
- Unattended installations of Fedora 31, CentOS 7, and CentOS 8 in text mode
It also installs the necessary kernel images for remote PXE clients to boot correctly.
- Apache Web Server: A minimally configured Apache server will serve local directory listings of all RPM packages.
You can access the local repositories via:
- http://hostname.localdomain/fedora31
- http://hostname.localdomain/centos7
- http://hostname.localdomain/centos8
Kickstart Files
This role also sets up Kickstart files for unattended installations of CentOS 7/8 and Fedora 31. These files are placed in a directory on the web server and can be accessed by all clients at:
Additional Notes
When creating a new virtual machine (VM) in VirtualBox or KVM, allocate at least 2 GB of RAM to ensure the CentOS installation works. You can reduce the RAM after a successful installation.
Users are encouraged to customize the Kickstart configuration templates, which currently have basic settings, including:
- Automatic disk partitioning with LVM
- SELinux turned off
- Firewall disabled
- Minimal software selection
- Root login allowed
- One non-root administrator user
- DHCP client network configuration
The goal is to minimize the work done by the Anaconda installer and focus on customizing the system after installation.
Requirements
Apache: You need Apache to access installation packages locally. Install it using:
ansible-galaxy install mariuszczyz.centos_apache
DHCP Service: A working local DHCP service is necessary. Alternatively, you can set up a separate DHCP on the PXE server using this role: CentOS & Fedora DHCP Server Installation and Configuration Ansible Role.
Operating System ISO Images: The installation images must be located in
/isos/
. You can change this path indefaults/main.yml
, but make sure the ISOs are downloaded before running this role.
Kickstart Files
For the Kickstart installation to function properly, you need to make at least this change:
rootpw --iscrypted PASSWORD_HASH
: This is the encrypted password for the root account.
To Create a Kickstart Root Password Hash
Run this command in the command line:
openssl passwd -6
This will prompt you for a password and give you an encrypted hash.
You can customize other settings to your needs, like disk partitions, time zone, and additional packages.
Role Variables
Variable | Description | Example |
---|---|---|
ISOS_PATH | Where the ISO images will be stored | /isos |
NAME | Name of the operating system | fedora31 |
ISO_LOCATION | Full ISO image path | /isos/CentOS-7-x86_64-Everything-1908.iso |
MOUNT_POINT | ISO mount point | /var/www/centos7 |
KICKSTART_HASHED_ROOT_PASSWORD | Hashed root password for Kickstart | bEzYf1S49$yu |
NON_ROOT_USER_NAME | Non-root admin username | mariusz |
NON_ROOT_USER_PASSWORD | Hashed user password for Kickstart | bEzYf1S49$yu |
TIMEZONE | Local timezone | America/Chicago |
NTP_SERVERS | Network time servers | ntp.localdomain |
FEDORA_HOSTNAME | Hostname for Fedora server | fedora31.localdomain |
CENTOS7_HOSTNAME | Hostname for CentOS 7 server | centos7.localdomain |
CENTOS8_HOSTNAME | Hostname for CentOS 8 server | centos8.localdomain |
Dependencies
You need the following dependencies:
Install these from Ansible Galaxy with requirements.yml
:
- src: mariuszczyz.centos_apache
- src: mariuszczyz.centos_dhcpd
Example Playbook
Manual Installation
You can fetch this role manually from Ansible Galaxy:
ansible-galaxy install mariuszczyz.centos_pxe
Using Galaxy
Alternatively, include it in requirements.yml
:
- src: mariuszczyz.centos_pxe
Or from GitHub:
- src: https://www.github.com/mariuszczyz/centos_pxe
Run this command to install all dependencies:
ansible-galaxy install -r requirements.yml
Running the Playbook
Create a new file (e.g., playbook.yml
) with the content:
- hosts: servers
user: YOUR USER
become: True
roles:
- { role: mariuszczyz.centos_pxe, tags: ['centos_pxe'] }
Run the playbook:
ansible-playbook -i hosts playbook.yml
License
BSD
Author Information
Author: Mariusz Czyz
Date: 12/2019
Website: mariuszczyz.com
CentOS 7/8 and Fedora PXE Boot Server Role
ansible-galaxy install mariuszczyz.centos_pxe