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”
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
Click on Partition Table Tab and Select “Default Kickstart”
Now Associate the Installation Media to this Operating system , Click on “Installation media” Tab and Select “CentOS_7_x86_64”
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.
Click on the “Provisioning template” i.e Kickstart default and associate the template to our operating System “CentOS 7.2”
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
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 :
click on Submit.
Next Screen will appear and will look like below.
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‘
From “Installation Media” Tab select the installation medium (CentOS_7_x86_64) that we have created in above steps.
Click on Submit
As we can see Provisioning Setup is completed. Our next task is to create the Host .
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”
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.
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.
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.
Once we click on Submit. Our New Host build status will become “Pending Installation”
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.
Whole installation will be performed in text mode.
Once the Installation is completed, installer will reboot your server. Login to the server and verify its OS version
From Foreman Dashboard verify the host details as well. Go To Hosts Tab —>Select All Hosts
Click on host “node1.example.com“, as we can see that build status has now changed to “installed”
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 🙂
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.
Which version of Katello do you use in the article?
Hi Tomas ,
I have used Foreman 1.13 not the katello in the above article. Though in Katello Setup Foreman also used for provisioning
I didn’t realise that you installed Foreman without the Katello plugin. That’s my bad really, thank you for the answer.
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.
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.
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.
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/’
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.
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
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
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?
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 🙂
@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”