Foreman – PXE Bare Metal & Virtual Machine Provisioning

Foreman is an open source package that provisions bare metal and virtual machine instances in public and private clouds. For provisioning, Foreman is able to do PXE-less and PXE installations of Bare Metal & VM servers. When doing PXE-less provisioning the bootdisk or discovery plugins are necessary. For PXE provisioning, Foreman makes use of PXE, DHCP, DNS, TFTP, and kickstart (CentOS & RHEL). After servers are provisioned, Foreman is able to configure servers using Puppet. Chef, Salt, Ansible, and Bash are also supported. Puppet is the default configuration tool installed with the Foreman server.

Let’s review the steps required to provision bare metal and virtual machines using PXE. This post assumes foreman is installed on CentOS 7 / RHEL 7.

Step:1 Create the OS installation media to be deployed on bare metal or VM servers

In our case, we have already created a yum server, and ftp server with CentOS 7 / RHEL 7 ISO images.

The CentOS 7 ISO file is mounted at “/var/ftp/pub/CentOS_7_x86_64

Login to Foreman and navigate to Hosts –> Installation media and select New Medium

Name of Installation Media : CentOS_x86_64

Path : ftp://<serverIP>/pub/CentOS_7_x86_64/

Choose Family as “Red Hat”


NOTE – Add creating installation media on repo server

Step:2 Provide operating system and deployment protocol information to Foreman

navigate to Hosts –> Operating systems and then select New Operating system

Name (of the OS): CentOS

Major version: 7

Minor version: 4

Description: CentOS 7.4

Family: Redhat

Root password hash: SHA256

Architectures: x86_64

Select the Partition Table Tab, then select Kickstart default in the listbox

Select the Installation media Tab, then select CentOS_7_x86_64 in the listbox


To define the Templates for our new Operating system, navigate to Hosts –> Provisioning Templates

We will select 5 templates, then associate these templates with our new Operating system CentOS 7.4

The first “Provisioning template” to select is Kickstart default and associate the template to our operating system CentOS 7.4 then Submit. Do the same with Kickstart default finish, Kickstart default iPXE, Kickstart default PXELinux, and Kickstart default user data.

Select Hosts –> Operating system, and select CentOS 7.4 to associate the templates from Associate tab


Step:3 Provide networking information to Foreman

Select the Infrastructure Tab -> Provisioning setup, then select the Foreman server that will be used for provisioning

Specify the subnet name and starting / ending ip addresses of the subnet

Name: cluster X addresses

Network address:

Start IP range:

End IP range:


Copy the foreman-installer command line from the Install provisioning with DHCP and paste it to a shell window on the foreman server.

# foreman-installer

Once the foreman-installer completes, select Next

Select the Installation Media Tab, then select existing media CentOS_7_x86_64


Step:4 (optional) Edit Provisioning Template (Kickstart Default) to download puppet from local repo

This step is optional. The default provisioning template assumes servers have Internet connectivity. This optional step shows how to modify the templet to use an internal repo server. Let’s assume puppet packages have been placed on our ftp server at /var/ftp/pub/puppet_rpms/

Select Hosts -> Provisioning Templates, then select Kickstart default

replace the puppet code:

repo –name=”EPEL”

with the puppet code:

repo --name=”puppet-pkg” --baseurl=

Also remove the epel-release package from the package list

Step:5 Configure ISC DHCP Server

Foreman DHCP & DNS proxies can work with ISC or Microsoft DHCP / DNS servers. For PXE Boot to function, the DHCP server on the PXE subnet must point to the Foreman TFTP server and pxelinux.0 bootfile when requested or the PXE boot will fail.

In this example, our subnet router that provides DHCP & DNS services is a Debian Linux based EdgeRouter by Ubiquiti Networks ( running EdgeOS 1.9.1

EdgeOS is a branch of router open source OS, Vyatta. EdgeOS contains the ISC dhcpd that can be configured to provide the necessary tftp reply.

a) ssh into the EdgeRouter

b) enter configure mode

% configure

c) Add the bootfile-server option to the dhcp configuration

# edit service dhcp-server shared-network-name LAN subnet

# set bootfile-server

d) Add the filename option to the dhcp config

set subnet-parameters “filename &quot;pxelinux.0&quot;;”

e) Add the bootfile-name option to the dhcp config

set bootfile-name pxelinux.0

f) Commit and Save the changes

# commit

# save

Step:# Create a New Host in Foreman that will be Provisioned

Select Hosts Tab –> New Host

Specify the name, Host Group, and other required parameters.

Name: bigaperf001

Deploy On: Bare Metal

NOTE – the Puppet Classes Tab is used to define puppet classes or modules that will be executed after the OS installation. This can allow additional software, configuration or tuning to be done after OS installation.

Select the Interface Tab to define ethernet interface parameters.

Specify the MAC address of the network interface on the server to be provisioned through foreman. The network interface name (such as enp0s3) and IP address will be gathered automatically from the provision subnet.


Select Operating System Tab

Select Operating system CentOS 7.2

Media CentOS_7_x86_64

Partition Table Kickstart default

Root password to be used during OS installation


The new Host build status will become Pending Installation

NOTE – New Hosts that will be provisioned in the same subnet, OS level, kickstart file, and deployment protocol can be added rapidly by starting at step#5.

Step:6 Provisioning bare metal or VM via PXE

Boot the server to be provisioned with PXE configured at the top of the boot order

The bare metal or VM will be assigned an IP address provided by the foreman DHCP server

OS installation will be performed in text mode following the kickstart script provided by Foreman

Once OS installation is finished, Foreman will reboot the server