Bare metal and Virtual Machine Provisioning through Foreman Server

Foreman is a free and open source tool that can provision bare metal and create virtual machine instances under public and provide cloud. Apart from the provision it is also used for configuring your system using puppet, it can perform perform all the repetitive task automatically using Puppet, chef, Salt and Ansible. Though Puppet is the default configuration tool that is being installed when we install Foreman server.

In our previous article we have already discussed “How to install Foreman Server on CentOS 7

In this article we will walk through the steps how bare metal and virtual machines are provisioned through foreman server. I am assuming foreman server is already installed on CentOS 7 / RHEL 7.

Step:1 Create the installation media

Let’s assume we want to install CentOS 7 as a operating system on bare metal servers or in virtual machines. For that first we need to create installation media from Foreman Dashboard.

Before creating installation media let’s share the contents of CentOS 7 ISO file via ftp. In my case i have already install ftp (vsftpd) on foreman server itself and copy the contents of CentOS 7 ISO file in “/var/ftp/pub/CentOS_7_x86_64“.

[root@foreman ~]# mkdir /var/ftp/pub/CentOS_7_x86_64
[root@foreman ~]# mount /dev/cdrom /mnt/
[root@foreman ~]# cp -apv /mnt/* /var/ftp/pub/CentOS_7_x86_64/

Now Login to your Foreman Dashboard , Go to Hosts Tab –> Select ‘Installation media‘ and Click on ‘New Medium‘ & Specify the followings

Name of Installation Media : CentOS_x86_64

Path : ftp://172.168.10.51/pub/CentOS_7_x86_64/

Choose Family as “Red Hat”

installation-media-foreman-server

click on “Submit

Step:2 Define the Operating System and Associate Templates

From your Foreman dashboard , Go to Hosts Tab –> Select “Operating systems” and then click on ‘New Operating system

From the Operating System Tab define the Name of the OS, its Major version and minor version, Description, Family and its Architectures. In my case i am putting the followings

operating-systems-definition-foreman-server

Click on Partition Table Tab and Select “Default Kickstart

operating-systems-partition-table-foreman-server

Now Associate the Installation Media to this Operating system , Click on “Installation media” Tab and Select “CentOS_7_x86_64

asssociate-installation-media-for-operating-systems-foreman

Click on Submit, We will come back here again once we define the templates for the newly created Operating system and then we will associate these templates from templates Tab.

To define the Templates for the Operating system , Go to Hosts Tab –> Select Provisioning Templates .

We will define 5 templates for our Operating system “CentOS 7.2“, These are highlighted in below screen.

provisioning-templates-foreman-server

Click on the “Provisioning template” i.e Kickstart default and associate the template to our operating System “CentOS 7.2”

provisioning-templates-operating-system-foreman-server

Click on submit.

Similarly Associate the remaining 4 templates to our operating system “CentOS 7.2”

Now again go to Hosts Tab –> Select Operating system, Click on CentOS 7.2, Associate the templates from Associate tab

associate-templates-centos-7-2-foreman

Click on Submit.

Step:3 Configure Provisioning Setup

Now from Infrastructure Tab Go to ‘Provisioning setup‘ and Click on “foreman.example.com” (i.e provisioning host in my case) , Specify the subnet name and other details like starting and ending ip of the subnet, as per my case i have used the followings :

network-config-foreman-setup-provision

click on Submit.

Next Screen will appear and will look like below.

foreman-installer-network-options

Copy the code under the option “Install provisioning with DHCP” and paste it on the foreman server. Once the installer command is completed then click on ‘Next

foreman-command-line

From “Installation Media” Tab select the installation medium (CentOS_7_x86_64) that we have created in above steps.

installation-media-foreman-installer

Click on Submit

As we can see Provisioning Setup is completed. Our next task is to create the Host .

provision-setup-completion-foreman-server

Step:4 (optional) Edit Provisioning Template kickstart Default.

This step is optional in case if your provision subnet has Internet connectivity because during provisioning installer will try to install puppet package from external repositories. In Case if you don’t have Internet connectivity then create your repository for puppet packages and update the repository info in provisioning template. In my case i have downloaded the required puppet package and its dependencies under the folder “/var/ftp/pub/puppet_rpms/

Go to “Provisioning Templates” from Hosts Tab , Select the “Kickstart default”

edit-provisioning-templates-foreman-server

Replace above highlighted code with below line

repo --name=”puppet-pkg” --baseurl=ftp://172.168.10.51/pub/puppet_rpms/

From this template file also remove epel-release package from the package list.Once you are done with these two changes , click on submit to save these changes.

Step:5 Create New Host for Provisioning

From the Hosts Tab –> Select New Host, Specify the name, Host Group and other required parameters.

new-host-creation-foreman-server

From the ‘Puppet Classes‘ we can attach the puppet class or modules to this host, which will be executed after the OS installation. In my case i am not touching this Tab

Define the interface parameters and its values from Interface Tab. Specify the MAC address of interface of your server which you want to provision through foreman. Interface name as ‘enp0s3‘ and IP address will be picked automatically from the provision subnet. Once you are done with settings then click on OK.

interface-settings-new-host-foreman-server

Go to the Operating system Tab, Select the Operating system “CentOS 7.2” , Media as “CentOS_7_x86_64” and Kickstart default as Partition Table and Root password that you want to set.

new-host-operating-system-details-foreman-server

Once we click on Submit. Our New Host build status will become “Pending Installation

new-host-pending-installation-foreman-server

Step:6 Boot Your Server or virtual Machine via PXE.

Now boot your bare metal Server or virtual machine via PXE, as we can see that server has picked the IP address from foreman DHCP server.

pxe-boot-server-foreman

Whole installation will be performed in text mode.

node1-installation-throgh-foreman-server

Once the Installation is completed, installer will reboot your server. Login to the server and verify its OS version

login-server-after-installation

From Foreman Dashboard verify the host details as well. Go To Hosts Tab —>Select All Hosts

all-hosts-foreman-server

Click on host “node1.example.com“, as we can see that build status has now changed to “installed

provisioned-host-details-foreman-server

That’s all for this article. Hope you guys got an idea how to provision bare metal and virtual machine through Foreman server. Please share your valuable feedback and comments 🙂

Share Now!

30 thoughts on “Bare metal and Virtual Machine Provisioning through Foreman Server”

  1. Pradeep,
    This is an awesome article, please contiue to provide more articles into more advance configurations if at all possible. The foreman community and those newcomers to this type of implementations greatly appreciate your contributions.

    Reply
  2. Hi pradeep,
    I too started exploring foreman and installed foreman 1.13 and provisioned setup in aws. Now i got a good article from you on server creation on bare metal.Thank you for your article.Please provide with our gmail id so for any queries , will contact you.

    Reply
  3. Hi Pradeep,

    You are amazing man!
    I installed Katello base on your instruction, it works like a charm in no time.
    You are the best! Please publish more article. I will read it all
    Thank you so much & very much appreciated your contribution.

    Reply
  4. hi, i am following your guide but facing a problem that how to ” download the required puppet package and its dependencies under the folder “/var/ftp/pub/puppet_rpms/” because i dont know which file to be download for repository and dependencies, please send me the exact link of those file.

    Reply
  5. Hi Naveen,

    In CentOS 7 server, set the puppet labs yum repository using following command :

    yum -y localinstall ‘http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm’

    Then use yumdownloader command to download puppet and its dependencies in a specific folder. Below is the url for reference.

    ‘https://ww.linuxtechi.com/download-rpm-using-yumdownloader-centos-7-rhel-7/’

    Reply
  6. Hi,
    Thank you for the reply,as per user guidance , i first install package “yum -y localinstall http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm” on a centos 7 server
    and Then use “yumdownloader puppetlabs-release –destdir /home/ftp/puppet –resolve” command to download puppet and its dependencies in a specific folder. At this time only one file was created and i put that file in my ftp server , but it didn’t worked , so i treid another command “yumdownloader puppet –destdir /home/ftp/puppet –resolve” command to download puppet and its dependencies ,At this time it created 10-15 files , again i treid to with all this file but again during provisioning the host says repository for puppet not available. In kickstart default provisioning template i am using the line repo –name=”puppet-pkg” –baseurl=ftp://myip/ftp/puppet.

    Reply
    • Hi Pradeep, I just cop up with this problem , i managed my new host to be connected to the internet during provisioning ,so there is no need of download the required puppet package and its dependencies, now i am facing another problem, during provising of host , the new host prompt for “please complete all spokes before continuing ” and ask to enter “b” to continue installation but , even afterentering “b” it takes me back to same window option, this is error related to ananconda , i cant attached pic but sending you link please check and suggest what could be possible error, either of template or something else. Thank you

      Reply
  7. hello i follow step by step in this article but i have problem ini pxe boot
    after i create new host and boot
    TFTP open timeout

    and why im not run in ipxe mode?
    pls help

    Reply
  8. I do all like you, but have error on “Instalation Source” and i don’t know why. I try 4 times all steps and all the time same result. I use content from CentOS-7-x86_64-Minimal-1611.iso this is can be a problem because minimal version?

    Reply
    • Ok, i know where is problem. I just unpack iso to my ftp catalog 🙂 When i mount iso and make rsync -avHPS /tmp/mnt/ /var/ftp/pub/CentOS_x86_64/ all works 🙂

      Reply
  9. @denzfarid,
    I have seen that issue with my lab once. Did you check if firewall port open for tftp/dhcp ? You may like to check Pradeep’s foreman install guide. Can you send the output of the command “firewall-cmd –list-all”

    Reply
  10. Nice Article.!! Really clear information.
    R u using the VMWARE workstation? or ESIX or Vecenter?

    I am trying the following steps but not yet succeed

    I am following this
    Step 1 : I have installed workstation in my window machine and In one VM, installing the centos and foreman on top of it.

    Step 2 : And another VM is VCENTER/ESXI server as compute resource .

    Step 3 : In provisioning setup, i will give the VCENTER IP details in foreman provisioning setup and as i dont have DNS and DCHP . I will give the static IP

    Step 4 : I will create the compute resource with V-CENTER IP and all other details

    Step 5 : Follow the steps of provisioning templates and all related stuff.

    Am i in right track. Please help me.. I am new to virtualization concepts and please correct me if I wrong direction

    Basically .. What I am thinking Foreman will provision the VM on host i.e compute host .. (BOTH IP are different foreman and compute host IP)

    VM-FOREMAN will contact COMPUTE VM PROVISON NEW VM on IT.

    Reply
    • Hi Phani,

      I have tested these steps on VirtualBox VMs and Bare metal Severs as well. First of all your Forman VM and target VM should be on the same vlan. My recommended way is to setup DHCP, DNS and TFTP service on Foreman(Steps are there in article), Create your installation media and update the provisioning templates and define your target vm in dashboard and then start your VM with pxe.

      Reply
      • Thanks for your response. I got it.
        Can you please also mention Step:3 Configure Provisioning Setup.. I gave my foreman IP address in network address ( in your case 172.168.10.0.). is that correct? is it the foreman server ip address or VMWARE cluster ip adress?
        Can you please help me .

        Also

        Reply
        • I am getting the following an error when i try to provision a VM in VMWARE. I think its may be because of newotking interfaces issue.

          Please let me know if you have any thoughts on this. Thanks

          Reply
        • It is not the Foreman or cluster IP, It is a Network address on which your DHCP server will start and will start assigning IP address to its clients from this network address only, In the network address we have specify the range of IP that can be used from this network address. From this range only Clients will get IP via DHCP.

          Reply
  11. Hey Pradeep .

    I dont have dhcp server in my environment. So I have given my own IP and defined my own template with user data and cloud init ( image based provision without ssh and I have one template template in vsphere. I gave the path of the location. So VM got created and i can login to VM also.
    Question 1 : But in foreman still the status of the host is “Pending for installation” not sure why its not showing that installation got completed.

    Question 2. In your case you ahve 5 templates are there. My question is where is the Centos ISO is location? will it be on foreman machine or Vsphere? or Its template will take care of the ISO part or will it downloaded and installed from internet?

    Question 3 : Also I ahve given the in host creation process as 136.123.24.123 but after VM created with ip 136.123.24.123 not sure why it got changed . Please help me on this.

    I really appreciated your supported . Thanks in advance please help me when you have some time

    Reply
  12. Small correction in Question 3 : Also I have given the IP in host creation process as 136.123.24.123 but after VM created with ip 136.123.24.12 not sure why it got changed . Please help me on this.

    Reply
  13. Hello All, I followed all the steps but my host is not booting up. Please help…
    My node is showing below mentioned error:

    Filename: node1.pxe
    tftp://10.0.2.4/node1.pxe… Permission denied

    Reply
  14. Hi Pradeep,

    Followed all steps, in /var/log/messages it appears that DHCP process is complete. However my machine is never installed with OS on PXE.

    Logs:

    Apr 18 21:49:36 foreman kernel: device enp4s0f0 left promiscuous mode
    Apr 18 21:49:43 foreman kernel: device enp4s0f0 entered promiscuous mode
    Apr 18 21:53:23 foreman dhcpd: DHCPDISCOVER from a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:53:23 foreman dhcpd: none: host unknown.
    Apr 18 21:53:23 foreman dhcpd: DHCPOFFER on 10.100.112.68 to a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:53:25 foreman dhcpd: Dynamic and static leases present for 10.100.112.68.
    Apr 18 21:53:25 foreman dhcpd: Remove host declaration jaime-smithee.controller or remove 10.100.112.68
    Apr 18 21:53:25 foreman dhcpd: from the dynamic address pool for 10.100.112.0/24
    Apr 18 21:53:25 foreman dhcpd: DHCPREQUEST for 10.100.112.68 (10.100.112.61) from a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:53:25 foreman dhcpd: DHCPACK on 10.100.112.68 to a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:53:25 foreman in.tftpd[32856]: RRQ from 10.100.112.68 filename pxelinux.0
    Apr 18 21:53:25 foreman in.tftpd[32856]: tftp: client does not accept options
    Apr 18 21:53:25 foreman in.tftpd[32857]: RRQ from 10.100.112.68 filename pxelinux.0
    Apr 18 21:53:25 foreman in.tftpd[32857]: Client 10.100.112.68 finished pxelinux.0
    Apr 18 21:53:25 foreman in.tftpd[32858]: RRQ from 10.100.112.68 filename pxelinux.cfg/0a84332b-8bef-e611-8c0b-f09838ae657a
    Apr 18 21:53:25 foreman in.tftpd[32858]: Client 10.100.112.68 File not found pxelinux.cfg/0a84332b-8bef-e611-8c0b-f09838ae657a
    Apr 18 21:53:25 foreman in.tftpd[32859]: RRQ from 10.100.112.68 filename pxelinux.cfg/01-a4-c6-4f-ca-5d-bd
    Apr 18 21:53:25 foreman in.tftpd[32859]: Client 10.100.112.68 finished pxelinux.cfg/01-a4-c6-4f-ca-5d-bd
    Apr 18 21:53:25 foreman in.tftpd[32860]: RRQ from 10.100.112.68 filename boot/CentOS-7.4.1708-x86_64-vmlinuz
    Apr 18 21:53:25 foreman in.tftpd[32860]: Client 10.100.112.68 finished boot/CentOS-7.4.1708-x86_64-vmlinuz
    Apr 18 21:53:25 foreman in.tftpd[32861]: RRQ from 10.100.112.68 filename boot/CentOS-7.4.1708-x86_64-initrd.img
    Apr 18 21:53:26 foreman in.tftpd[32861]: Client 10.100.112.68 finished boot/CentOS-7.4.1708-x86_64-initrd.img
    Apr 18 21:54:22 foreman dhcpd: DHCPDISCOVER from a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:54:22 foreman dhcpd: DHCPOFFER on 10.100.112.68 to a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:54:22 foreman dhcpd: Dynamic and static leases present for 10.100.112.68.
    Apr 18 21:54:22 foreman dhcpd: Remove host declaration jaime-smithee.controller or remove 10.100.112.68
    Apr 18 21:54:22 foreman dhcpd: from the dynamic address pool for 10.100.112.0/24
    Apr 18 21:54:22 foreman dhcpd: DHCPREQUEST for 10.100.112.68 (10.100.112.61) from a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:54:22 foreman dhcpd: DHCPACK on 10.100.112.68 to a4:c6:4f:ca:5d:bd via enp4s0f0
    Apr 18 21:54:26 foreman smart-proxy: localhost – – [18/Apr/2018:21:54:24 +0530] “DELETE /puppet/ca/jaime-smithee.controller HTTP/1.1” 404 77
    Apr 18 21:54:26 foreman smart-proxy: – -> /puppet/ca/jaime-smithee.controller
    Apr 18 21:54:26 foreman smart-proxy: localhost – – [18/Apr/2018:21:54:26 +0530] “POST /puppet/ca/autosign/jaime-smithee.controller HTTP/1.1” 200 0
    Apr 18 21:54:26 foreman smart-proxy: – -> /puppet/ca/autosign/jaime-smithee.controller

    Could you please help.

    Reply
  15. Hi Pradeep,
    Awesome article ! In Foreman 1.16.1 with Katello 3.5. I am not seeing any Provisioning Setup Tab in Infrastructure. Is that changed now in new version. Do you have any article for newer version.

    Reply
    • I have the same inconvenience. My lab setup (foreman 1.20) has two NICs, one of them is for NAT so I can download packages, and the last one is for local network. So far I can not configure provisioning over PXE. Some help I’ll appreciate.

      Reply

Leave a Comment