- Operating System
- Install Foreman on CentOS 7 / RHEL 7
- Access Foreman Web Console
- Download and Install NTP module
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.
- 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
This article is based on RHEL 7 / CentOS 7 .
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 )
184.108.40.206 sapin-centos7.syslint.com sapin-centos7
Also update the hostname file too inside /etc/hostname
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.
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
Run the following command to download Foreman installer.
# yum -y install 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
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.
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.
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.
We have successfully configured Foreman and now it is ready to accept agents / nodes. It’s time to add some new hosts to Foreman.