How to install and configure Foreman on Ubuntu 16.04

Image for post
Image for post

By Hitesh Jethva, Alibaba Cloud Community Blog author.

Foreman is a free and open source systems management tool for provisioning, configuring and monitoring of physical and virtual servers. Foreman can be used to discover, provision and upgrade your entire bare-metal infrastructure, create and manage instances across private and public clouds. Foreman can integrate with other configuration management software like, Puppet, Chef and Salt that allows you to automate repetitive tasks, deploy applications, and manage change to deployed servers. Foreman provides user friendly web interface that allows you to install and apply puppet modules to the registered servers to automate day to day operations tasks. It is specially designed for infrastructures of all sizes, and works with most distributions of Linux. Foreman supports on all the major operating systems like, RHEL /CentOS/Fedora, Ubuntu/Debian, CoreOS, FreeBSD, Junos, Solaris, OpenSUSE and much more.

In this tutorial, we will learn how to install and configure Foreman on Ubuntu 16.04 server with an Alibaba Cloud Elastic Compute Service (ECS) instance.

Requirements

  • A fresh Alibaba Cloud instance for server with Ubuntu 16.04 server installed.
  • A fresh Alibaba Cloud instance for client instance with Ubuntu 14.04 installed.
  • A static IP address 192.168.43.192 is set up on the Server instance and 192.168.43.11 is set up on the Client instance.
  • A root password is set up on both instances.

Launch Alibaba Cloud ECS Instance

Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM, and connect to your instance as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

Getting Started

First, you will need to configure hostname and hostname resolution on both instances. So, each instance can communicate with each other by hostname.

On the server instance, setup hostname with the following command:

Next, configure hostname resolution by editing /etc/hosts file:

Add the following line:

Save and close the file, when you are finished.

On the client instance, setup hostname with the following command:

Next, configure hostname resolution by editing /etc/hosts file:

Add the following line:

Save and close the file, when you are finished.

Install Foreman

The Foreman installer is a collection of Puppet modules that install everything required for a full working Foreman setup. It comes with all the necessary components like, Foreman, Puppet master and agent, Apache Web Server with SSL and Passenger module.

By default, Foreman is not available in the Ubuntu 16.04 default repository. So, you will need to add the Puppet and Foreman repository to your server.

First, install Puppet repository with the following command:

Next, add the Foreman repository with the following command:

Add the following lines:

Save and close the file. Then, add the GPG key with the following command:

Next, update the repository and install Foreman installer with the following command:

Next, run the Foreman installer with the following command:

Once the installation has been completed successfully, you should see the following output:

Note : Please remember the admin username and password from the above output. You will need this to access Foreman web interface.

Access Foreman Web Interface

Open your web browser and type the URL https://node1.example.com. You will be redirected to the Foreman login page:

Image for post
Image for post

Now, provide your admin username and password. Then, click on the Log In button. You should see the following page:

Image for post
Image for post

Next, it is recommended to change the current password of Foreman admin user. To do so, click on the username >> My Account. You should see the following page:

Image for post
Image for post

Now, change your password and click on the Submit button.

Next, click on the Hosts >> All Hosts button to see the available hosts:

Image for post
Image for post

Foreman host is not visible in the above image. So, you will need to run the following command:

This command will send the first Puppet agent report to Foreman and automatically create the host in Foreman’s database.

Now, click on the Hosts >> All Hosts button again to see the Foreman host in the following page:

Image for post
Image for post

Install NTP Module to Foreman

Puppet requires accurate time-keeping. So you will need to install NTP module to manage the NTP service on the Foreman host.

You can install NTP module by running the following command:

Output:

On the Foreman dashboard, go to Configure >> Puppet >> Classes. You should see the following page:

Image for post
Image for post

Now, click on the Import from node1.example.com to read the available Puppet classes from the puppet master and populate Foreman’s database:

Image for post
Image for post

Now, select the NTP module and click the Update button. You should see the following page:

Image for post
Image for post

Now, click on the Configure >> Smart Class Parameter >> Servers. You should see the following page:

Image for post
Image for post

Here, select Override checkbox, change Key Type to array, change the Default value to your NTP server and click on the Submit button.

Next, go to Hosts >> All Hosts. You should see the following page:

Image for post
Image for post
Image for post
Image for post

Now, click on the Edit button, go to Puppet Classes tab and expand the ntp module and click the + icon to add the ntp class to the host, then click on the Submit button. You will be redirected to the host details page:

Image for post
Image for post

Now, click on the YAML button. You should see the ntp class and the servers parameter in the following page:

Image for post
Image for post

Install Puppet Agent on Client Instance

By default, Puppet agent is not available in the Ubuntu 14.04 default repository. So, you will need to add the Puppet repository to your client instance. You can do this by running the following command:

Next, update the repository and install Puppet agent with the following command:

Once the installation has been completed, you will need to update the Puppet default configuration file.

Make the following changes:

Next, run the following command to enable and run puppet agent service.

Finally, restart the Puppet agent service with the following command:

Sign Puppet Agent Certificate

Now, go to the Foreman server instance and list down the unsigned certificates with the following command:

You should see the following output:

Now, sign the certificate with the following command:

Output:

On the Foreman dashboard, go to Infrastructure >> Smart proxies and select the Certificates from drop down. you should see the server and client certificate in the following page:

Image for post
Image for post

Now, go to Hosts >> All Hosts. you should see the newly added client node in the following page:

Image for post
Image for post

Original Source

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store