HostSEO Blog

Stories and News from IT Industry, Reviews & Tips | Technology Blog


How to install and configure Foreman on CentOS 7 or RHEL 7

1. Introduction

Foreman is an open source tool that can help with the management of servers, by providing an easy way to interact with Puppet (or Chef) to automate tasks and application deployment. Foreman provides a robust web user interface, API, and CLI which can be used to provision, configure, and monitor your servers. It is suitable for infrastructures of all sizes, and works with most distributions of Linux.

In this tutorial, we will show you how to install Foreman with Puppet, and start using it to manage your servers. We will use Foreman for its reporting and External Node Classifier (ENC) capabilities, to ease the management of Puppet.

2. Features

  • Discover, provision and upgrade your entire bare-metal infrastructure
  • Create and manage instances across private and public clouds
  • Group your hosts and manage them in bulk, regardless of location
  • Review historical changes for auditing or troubleshooting
  • Extend as needed via a robust plugin architecture
  • Automatically build images (on each platform) per system definition to optimize deployment

3. Operating System

This article is based on RHEL 7 / CentOS 7 .

4. Prerequisites

Before installing Foreman, make sure you have setup a hostname and its dns properly for your server. You can edit the file /etc/hosts and update it as follows:( it is an example )

138.201.3.24 sapin-centos7.syslint.com  sapin-centos7

Also update the hostname file too inside /etc/hostname

sapin-centos7.syslint.com

5. Install Foreman on CentOS 7 / RHEL 7

Foreman can be installed in different methods. The recommended way is with the puppet based Foreman Installer but you may also use your distribution’s package manager or install directly from source.

The Foreman installer is a collection of Puppet modules that installs everything required for a full working Foreman setup. It uses native OS packaging (e.g. RPM and .deb packages) and adds necessary configuration for the complete installation.

The Foreman installer will install the necessary components such as the Foreman web UI, Smart Proxy, Passenger (for the puppet master and Foreman itself), and optionally TFTP, DNS and DHCP servers.

5.1. Configure EPEL, Puppet and Foreman repositories

Please run the below command for enabling the EPEL , pupet and forman repos.

# rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
#rpm -ivh http://yum.theforeman.org/releases/1.9/el7/x86_64/foreman-release.rpm

Enable the RHEL Optional and RHSCL repos on RHEL 7 ### run the below command.

# yum-config-manager --enable rhel-7-server-optional-rpms rhel-server-rhscl-7-rpms

5.2. Download Foreman installer

Run the following command to download Foreman installer.

# yum -y install foreman-installer

5.3. Start installation of foreman

# foreman-installer

Once the installation is completed, you will see an output like below where you would find the initial username and password to access the Foreman.

Installing  Done    [100%][.................................................]
  Success!
  * Foreman is running at https://sapin-centos7.syslint.com
      Initial credentials are admin / KMq5Eoo8KHVtQPeh
  * Foreman Proxy is running at https://sapin-centos7.syslint.com:8443
  * Puppetmaster is running at port 8140
  The full log is at /var/log/foreman-installer/foreman-installer.log

Note down initial username and password, you need this for accessing Foreman’s dashboard.

Username :: admin
Password :: testpas

5.4. Configure Foreman (Optional)

If your Foreman host is not visible in Hosts –> All Hosts tab, you should run below command which will send the first Puppet report to Foreman, automatically creating the host in Foreman’s database.

# puppet agent --test

You will get an out like below

Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for sapin-centos7.syslint.com
Info: Applying configuration version '1452312143'
Notice: Finished catalog run in 0.08 seconds

Puppet 3+ will show a warning the first time that the node can’t be found, this can be ignored.

6. Access Foreman Web Console

You can access the Foreman via web browser https://your-ip-address or https://FQDN

You should get login page, enter your Foreman credentials.

To list down the available hosts, goto Hosts –> All Hosts from Menu. Since we do not have any puppet clients, All Hosts tab would only list your Foreman host, with an “O” status. This indicates its status is OK, with no changes made on the last Puppet run. If your Foreman host is not shown here, check out configuring Foreman.

7. Download and Install NTP module

One of the more important requirement of puppet is to have an accurate time-keeping, to do this, we will install Puppet NTP module for managing the NTP service.

If you have Puppet 2.7.14 or higher, install the module automatically from Puppet Forge to our “production” environment (the default).

Use following command to install NTP module on Foreman (Puppet master) host.

# puppet module install -i /etc/puppet/environments/production/modules saz/ntp

You will get the below out.

Notice: Preparing to install into /etc/puppet/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/environments/production/modules
└── saz-ntp (v2.3.2)

In Foreman’s web console, go to Configure > Puppet Classes and click Import from hostname (sapin-centos7.syslint.com) to read the available Puppet classes from the puppet master and populate Foreman’s database.

Select the NTP module and click the update button.

After clicking the update button, you will see something like below. The “ntp” class will appear in the Puppet class list if installed correctly. Click on First NTP class on the left.

Now, Click the Smart Class Parameter and then select server list on the left side. Tick the Override checkbox so Foreman manages the “server list” parameter of the class, then click Submit.

Go to Hosts –> All Hosts, edit the Foreman host.

Go to Puppet Classes tab and expand the ntp module and click the + icon to add the ntp class to the host, then click submit.

This time, it will take you automatically to the host details page. Click on YAML, it will show the ntp class and the server list parameter, as passed to Puppet via the ENC (external node classifier) interface.

At last, run the following command on the Foreman host to see the NTP service automatically reconfigured by Puppet and the NTP module.

# puppet agent --test

Verify the installation of NTP module by going to Hosts –> All Hosts –> Select Foreman Host –> Reports –> Select latest report.

8. Conclusion

———-

We have successfully configured Foreman and now it is ready to accept agents / nodes. It’s time to add some new hosts to Foreman.

Subscribe Now

10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!

Archive Calendar

SatSunMonTueWedThuFri
 1
2345678
9101112131415
16171819202122
23242526272829
30 

Born in 2004 ... Trusted By Clients n' Experts

SEO Stars

They never made me feel silly for asking questions. Help me understand how to attract more people and improve my search engine ranking.

Read More

Emily Schneller Manager at Sabre Inc
SEO Stars

Took advantage of Hostseo's superb tech support and I must say, it is a very perfect one. It is very fast, servers reliability is incredible.

Read More

Leena Mäkinen Creative producer
SEO Stars

We're operating a worldwide network of servers with high quality standards requirements, we’ve choose hostseo to be our perfect partner.

Read More

Ziff Davis CEO at Mashable
SEO Stars

It’s very comfortable to know I can rely about all technical issues on Hostseo and mostly that my website and emails are safe and secured here.

Read More

Isaac H. Entrepreneur
SEO Stars

With hostseo as a hosting partner we are more flexible and save money due to the better packages with great pricing, free SEO n' free SSL too!

Read More

Madeline E. Internet Professional