Introduction
Provisioning Bare metal or virtual machine is the most important requirement for any system admin to eliminate the manual intervention to build a server. The opensource foreman tool provides us with production-grade features totally free of cost.
If you are looking for preparing Red Hat certification RH403 or RH404 this is your playground. You will get all the features available in Red Hat Satellite 6.x.
In our previous guide, we have gone through how to set up a foreman and how to register a Linux client with it. Now’s it’s time to provision few physical hosts from the foreman user interface. At the end of this guide, you will be more confident how it easy to provision a bare metal without any manual intervention.
For successful provisioning we need to have a Medium, Operating system, host groups, provisioning setup and Host creation. In this guide, Let’s start with creating a medium, To serve the Medium/Packages we will set up a local Apache webserver on our foreman server. Instead, you can set up the same in other servers as well.
Apart from this, we need to have a working DNS and DHCP. The DHCP server from the router should not overlap with the foreman DHCP we are about to set up. So make sure to use a different range of scopes.
Firewall Requirement
Enable the required ports by allowing the service.
# firewall-cmd --add-service=RH-Satellite-6 --permanent # firewall-cmd --reload
Make sure to run --reload
option to take effect.
Knowing Organization & Location
To create a medium and creating Operating System we need to make sure creating under the right organisation and location. In our setup we have only one location and organisation.
[root@foreman ~]# hammer organization list
---|-----------------------|-----------------------|-------------|----------------------
ID | TITLE | NAME | DESCRIPTION | LABEL
---|-----------------------|-----------------------|-------------|----------------------
1 | LinuxSys Organization | LinuxSys Organization | | LinuxSys_Organization
---|-----------------------|-----------------------|-------------|----------------------
[root@foreman ~]#
The location is as follow.
[root@foreman ~]# hammer location list
---|-----------|-----------|------------
ID | TITLE | NAME | DESCRIPTION
---|-----------|-----------|------------
2 | MyHomeLab | MyHomeLab |
---|-----------|-----------|------------
[root@foreman ~]#
Once we get that information we need to substitute that information with the hammer command and options to create the remaining steps to successfully set up provisioning on foreman server.
Running a Temporary Web Server
In our setup we are not going to get the medium from online, Instead, we will try to mount a medium locally under the default document root of the Apache webserver.
Let’s run a local temporary web server using python. Mount the ISO file under any location and navigate to the mount location, by following run the python command.
# mount -t iso9660 /var/lib/vz/template/iso/CentOS-7-x86_64-Everything-2003.iso /mnt/ # cd /mnt/ # python -m SimpleHTTPServer 80
Now you will get a working web server with your mounted medium.
http://192.168.0.11/
This is just a temporary solution.
Running a Permanent WebServer
To make a permanent solution for serving our medium let’s set up an apache web server by installing httpd package.
# yum install httpd -y
Enable and start the service.
# systemctl enable httpd # systemctl start httpd
As we know the default root directory of apache web server let’s mount the DVD under document root by creating a directory.
# mkdir /var/www/html/pub/CentOS78 # mount /dev/sr0 /var/www/html/pub/CentOS78/
Now we are good with accessing below URL.
http://192.168.0.19/pub/CentOS78/
Next step is to create a medium for our provisioning.
Listing the available Medium
Before creating any medium, we will get the listed medium by default.
To list the currently available medium from CLI.
[root@foreman ~]# hammer medium list
---|----------------------|------------------------------------------------------------------------------
ID | NAME | PATH
---|----------------------|------------------------------------------------------------------------------
1 | CentOS mirror | http://mirror.centos.org/centos/$major/os/$arch
8 | CoreOS mirror | http://$release.release.core-os.net
2 | Debian mirror | http://ftp.debian.org/debian
4 | Fedora Atomic mirror | http://dl.fedoraproject.org/pub/alt/atomic/stable/Cloud_Atomic/$arch/os/
3 | Fedora mirror | http://dl.fedoraproject.org/pub/fedora/linux/releases/$major/Server/$arch/os/
5 | FreeBSD mirror | http://ftp.freebsd.org/pub/FreeBSD/releases/$arch/$version-RELEASE/
6 | OpenSUSE mirror | http://download.opensuse.org/distribution/leap/$version/repo/oss
9 | RancherOS mirror | https://github.com/rancher/os/releases/download/v$version
7 | Ubuntu mirror | http://archive.ubuntu.com/ubuntu
---|----------------------|------------------------------------------------------------------------------
[root@foreman ~]#
Creating the Installation Media
To create a installation medium navigate to
hosts –> Installation Media –> Create Medium
Enter the name “CentOS7_local” and URL as “http://192.168.0.19/pub/CentOS78” and click create.
To create one from the command line is super easy by running hammer command with options and arguments.
# hammer medium create --location "MyHomeLab" --organization "LinuxSys Organization" --name "CentOS7_local" --path "http://192.168.0.19/pub/CentOS78/" --os-family "Redhat"
List the created medium from the command line.
[root@foreman ~]# hammer medium list
---|----------------------|------------------------------------------------------------------------------
ID | NAME | PATH
---|----------------------|------------------------------------------------------------------------------
10 | CentOS7_local | http://192.168.0.19/pub/CentOS78
1 | CentOS mirror | http://mirror.centos.org/centos/$major/os/$arch
8 | CoreOS mirror | http://$release.release.core-os.net
2 | Debian mirror | http://ftp.debian.org/debian
4 | Fedora Atomic mirror | http://dl.fedoraproject.org/pub/alt/atomic/stable/Cloud_Atomic/$arch/os/
3 | Fedora mirror | http://dl.fedoraproject.org/pub/fedora/linux/releases/$major/Server/$arch/os/
5 | FreeBSD mirror | http://ftp.freebsd.org/pub/FreeBSD/releases/$arch/$version-RELEASE/
6 | OpenSUSE mirror | http://download.opensuse.org/distribution/leap/$version/repo/oss
9 | RancherOS mirror | https://github.com/rancher/os/releases/download/v$version
7 | Ubuntu mirror | http://archive.ubuntu.com/ubuntu
---|----------------------|------------------------------------------------------------------------------
[root@foreman ~]#
Creating an Operating System
Let’s create an Operating system for provisioning. Navigate to
Hosts –> Operating Systems –> Create Operating System
- Name of the Operating System.
- The major version of the Operating system we are about to create.
- The minor version of the Operating system.
- Give short description for our Operating system.
- Select the family from the drop-down list as Red Hat.
- The Root password hash required to use.
- select the applicable architectures by clicking on the arrow in the middle.
- Click “Submit” to create the Operating system. But this will be done after selecting a few more options from other tabs.
Select the Partition Table tab and assign the Kickstart default by clicking on it.
By following, we need to select the appropriate installation media which we created in our earlier step. If you need to download the package from internet choose “CentOS mirror” from the list other than CentOS_local.
Once the Operating System created we should get the all available OS as shown below.
Let’s start with configuring provisioning.
Preparing Provisioning setup
Once our medium and Operating systems are in place, the next step is to create the provisioning by navigating to
Infrastructure –> Provisioning setup
Here, there are 5 steps need to be completed for setting up provisioning.
Resolving Pre-Requisties
Before continuing with any steps we should have a working foreman with at-least one network interface. If we have multiple interfaces it can choose from the list.
Configuring Network for Provisioning Bare Metal
In the second step of provisioning setup we need to configure the network configuration.
- The default domain will be there.
- Give a name for your new subnet about to create for provisioning.
- Select the IPv4 to enter the IPv4 details.
- Gateway of your network.
- A valid local DNS server to resolve the hostname and it’s important for Provisioning.
- The default boot mode for the interface.
Click the Submit button to move forward.
Running and installing Foreman Installer
In this step, we need to copy the output from the screen which populated by the collected information in our earlier provisioning setup steps. Switch back to foreman server shell and run it to complete the setup.
The output will be different in your setup according to your network.
foreman-installer \
--enable-foreman-proxy \
--foreman-proxy-tftp=true \
--foreman-proxy-tftp-servername=192.168.0.19 \
--foreman-proxy-dhcp=true \
--foreman-proxy-dhcp-interface=ens18 \
--foreman-proxy-dhcp-gateway=192.168.0.1 \
--foreman-proxy-dhcp-nameservers="192.168.0.21,192.168.0.1" \
--foreman-proxy-dns=true \
--foreman-proxy-dns-interface=ens18 \
--foreman-proxy-dns-zone=linuxsysadmins.local \
--foreman-proxy-dns-reverse=0.168.192.in-addr.arpa \
--foreman-proxy-dns-forwarders=192.168.0.21 \
--foreman-proxy-dns-forwarders=192.168.0.1 \
--foreman-proxy-dns-forwarders=8.8.8.8
Once the setup completed we should get the output similar to below.
Preparing installation Done
Success!
* Katello is running at https://foreman.linuxsysadmins.local
* To install an additional Foreman proxy on separate machine continue by running:
foreman-proxy-certs-generate --foreman-proxy-fqdn "$FOREMAN_PROXY" --certs-tar "/root/$FOREMAN_PROXY-certs.tar"
The full log is at /var/log/foreman-installer/katello.log
[root@foreman ~]#
Click Next
Selecting Installation Media
In the next step select the existing custom medium we created.
Click Submit to complete the provisioning setup.
Completed Provisioning Setup
Once we get the completion stage it’s time to continue with remaining configuration by configuring hosts groups and creating hosts.
The next step we are going to perform is to configure the Host Groups.
Continue reading by clicking on Next Page.