Install and set up Foreman on Ubuntu 16.04/18.04

Im Durchschnitt wird dieses Tutorial Install and set up Foreman on Ubuntu 16.04/18.04 mit 5 bewertet, wobei 1.0 die schlechteste und 5.0 die beste Bewertung ist. Es haben insgesamt 151 Besucher eine Bewertung abgegeben.
151 0

Install and set up Foreman on Ubuntu 16.04/18.04

Foreman Ubuntu

You’re getting your server from our panel and you’re looking for a solution to pull up a system with a few mouse clicks or a command line call that doesn’t need any configuration work anymore but becomes productive and a way to automate repetitive tasks, quickly deploy applications and proactively manage servers onsite or in the cloud? Then this tutorial is for you. I’ll show you how to install and configure Foreman on Ubuntu 16.04/18.04 and how to get started with Foreman’s Web UI.
But even if your server doesn’t run on our panel, you can still read on and benefit from the information I provide. ­čśë You might also be interested to learn more about us, what we do and what services we offer. About us, as well as what we offer, we tell you on our website and about our services you can read more in our articles How to gridscale, Getting started with PaaS at gridscale, Getting started with Cloud Automation, Getting started with the gridscale Load Balancer, Getting Started with the gridscale API and gridscale API documentation.

About Foreman

Foreman is a complete lifecycle management tool for physical and virtual servers. There are orchestration tools such as Chef, Puppet and Saltstack to help you unify the administration of your system landscape. But they don’t do everything. This is where Foreman comes in. Foreman provides a unified interface for everything, because you can use it to update and deploy your entire infrastructure and keep track of it. Foreman consists of a server process that controls the other components, so-called smart proxies that communicate with other services (e.g. Puppet, DHCP, DNS, TFTP), and a Web-U.

Once the managed system is installed and the Puppet client is installed using the template parameters, Foreman implements the stored Puppet classes. Another annoying step in practice is the search for the answer to the question: Which is the next free IP address? Foreman can assign this freely when creating a new host or simply take the next free IP from the network pool – including entries in the DNS forwards and backwards.

In addition, Foreman integrates with various cloud & virtualization platforms such as Open Stack, O-Virt, VMware, Rackspace, and Amazon’s AWS, allowing functionality to work in a virtualized environment.

Create and manage instances in private and public clouds. Group your hosts and manage them in bulk, regardless of location. Foreman also provides a RESTful API, CLI, web frontend that lets you create higher-level business logic and interact with the software.

Set the hostname and the FQDN

First configure the hostname on your system using the two commands shown below. “foreman” serves as a placeholder for the hostname and you can replace it according to your needs.

hostnamectl set-hostname 'foreman'
exec bash

The hostname should then be implemented in the hostname file located in the directory. You can check whether the name has been entered in the file with the command shown below. The output should match the set hostname accordingly.

cat /etc/hostname

In addition, you can also use the command from the following code snippet in the terminal. The output should then be the hostname you assigned.


Set the Fully Qualified Domain Name (FQDN) after this. The FQDN consists of the host name and the domain name. You can read more information about this in our article Changing Hostname and Fully Qualified Domain Name (FQDN) on Ubuntu 16.04. You already know what the hostname is, because I have just defined it. But what is the domain name? You can find this out using the command shown below.


cat /etc/resolv.conf

An output is then generated, as shown in the following screenshot. I have marked where you can find the information about the domain name.

Output von Kommando cat /etc/resolv.conf

In my case, the domain name is To finally set the FQDN, you need to edit the /etc/hosts file with any text editor. I do this – as shown in the following command – with the nano editor.

nano /etc/hosts

Add the information about the FQDN to your server as you see it in the code snippet below, adapted accordingly with your own data. Replace the placeholder IP with the public IP of your server.

IP foreman

If you are referring your Ubuntu server through our Panel, then the Public IP would be the one you see in the screenshot, with a pink border.

IP-Adresse eines Server im gridscale-Panel

After your update, save the file /etc/hosts in the nano editor with the key combination Ctrl+O and exit the editor with Ctrl+X.

Then check to see if your hostname and FQDN definitions work on your server, starting with the commands presented below.

hostname -a

The output to each of the two commands shown above in relation to my example would be: foreman

You can also display the FQDN with the following command.

hostname ÔÇôf

The output to this would be in relation to my example:

You can also use the following command to display the set domain name separately.

hostname ÔÇôd

The output to this would be in relation to my example:

You can also have the complete contents of the hosts file played using the following command.

cat /etc/hosts

Install Foreman and some components

Here we go with the installation. The best thing to do first is to update your server.

apt-get update && apt-get upgrade

First, you should add a set of CA certificates to your server using this command.

apt-get install ca-certificates

Then use the following commands to activate Puppet 5 repositories.

If using Ubuntu 16.04:

dpkg -i puppet5-release-xenial.deb

If using Ubuntu 18.04:

dpkg -i puppet5-release-bionic.deb

Use the commands below to activate Foreman 1.19 repositories.

In the case of Ubuntu 16.04:

echo "deb xenial 1.19" | sudo tee /etc/apt/sources.list.d/foreman.list

In the case of Ubuntu 18.04:

echo "deb bionic 1.19" | sudo tee /etc/apt/sources.list.d/foreman.list

In the case of both Ubuntu versions these two commands would still have to be executed.

echo "deb plugins 1.19" | sudo tee -a /etc/apt/sources.list.d/foreman.list
wget -q -O- | sudo apt-key add -

Depending on the version, you can change the version number of Puppet and/or in the commands presented above. Be sure to check the compatibility between the Puppet and Foreman versions. If you want to change the version number(s), you should check how to do that on the internet . Use the command below to install the Foreman installer. The Foreman Installer is the installation tool for Foreman.

apt-get update && apt-get -y install foreman-installer

Then install Foreman using the Foreman Installer. This will install the following components: Foreman Web UI (Apache HTTP with SSL), Puppet Master, Puppet agent, Smart Proxy and TFTP Server. You can replace testpassword with a password of your choice.

foreman-installer --foreman-admin-username admin --foreman-admin-password "testpassword"

You should get an output similar to the one in the screenshot below.

Output nach Installation des Foreman-Installers

Configure your Firewall

After you have installed Foreman and its components, you will need to make a number of ports accessible to your firewall. To do this, execute the commands shown below.

ufw allow 53,80,443,3000,3306,5432,8140,8443/tcp
ufw allow 67:69/udp
ufw allow 5910:5930/tcp

Finally, activate the firewall services.

ufw enable

The firewall then prompts you to accept the changes in a generated dialog.

Configure Foreman and the components

Foreman needs its own database – database sharing is not supported. By default, the installer uses PostgreSQL, while a package or source installation uses SQLite. If you want to use a different database (e.g. MySQL), you will need to change the configuration file at config/database.yml. Use the production settings in all cases. See the Foreman documentation for more information. To initialize the database schema and content, execute the following two commands:

foreman-rake db:migrate
foreman-rake db:seed

After that it is necessary to change a value in the /etc/foreman/settings.yaml configuration file. With the command shown below you would open it in the nano editor.

nano /etc/foreman/settings.yaml

In it you have to change the value of :puppetrun:. As you can see from the screenshot, it is set to false by default. You have to change it to true, then save it with Ctrl+O and quit the nano editor with Ctrl+X. You don’t have to change the values of the other parameters. But if you’re interested in information about their meaning, you’ll also find it in the Foreman documentation.

Anpassung der Konfigurationsdatei unter /etc/foreman/settings.yaml im nano-Editor

Finally, you add the Foreman host to the Foreman database.

/opt/puppetlabs/bin/puppet agent --test

A similar output should then be generated for you, as you can see in the following screenshot.

Output nach Hinzuf├╝gen des Host zur Foreman-Datenbank

Then start and check the Foreman and Puppet services by executing the four commands listed below. You can exit each status mode by pressing Ctrl+Z.

systemctl start foreman
systemctl status foreman
systemctl start puppet.service
systemctl status puppet.service

Getting started with the Web UI of foreman

Open your web browser and visit http://localhost by swapping localhost with the IP of your server to access the Foreman web interface. Alternatively, you can use http://FQDN, where you exchange the placeholder FQDN with the FQDN you know. In this case you would also have to create a DNS entry. Once you reach the Foreman web interface in your browser, you will first see the login page. Enter your Foreman username (admin) and the previously created password (in my case: testpassword) and then click the Login button.

Login-Seite des Foreman Web UI

This will bring up the main page where you can see a status overview, such as an entire host configuration status and a host configuration status for Puppet.

├ťbersichtsseite des Foreman Web UI

In the menu on the left you will find the All Hosts menu item in the submenu of the Hosts menu item.

Alle Hosts-Men├╝punkt aufrufen im Foreman Web UI

On the Hosts page you have an overview and the possibility to access existing hosts. You can also add new hosts via the Create Host button or export them via the Export button.

Hosts-Seite im Foreman Web UI

Clicking on the host name will take you to the details page of that host, where you will find an overview of its properties, runtime graphs, and resources.

Detailseite eines Hosteintrags im Foreman Web UI


Wow! That was quite uncomplicated and didn’t take long. You now have a lifecycle management tool with which you can keep an eye on your entire server infrastructure and automatically regulate all processes and manage your server proactively. Maybe I made you – if you didn’t know us or our services yet – a little curious. In any case, I enjoyed showing you how to get your Ubuntu server up and running for Foreman and helping you get started with Foreman’s Web UI. ­čÖé

From our column to Foreman also still interesting and helpful:

You’re getting your server from our panel and you’re looking for a solution to pull up a system with a few mouse clicks or a command line call that doesn’t need any configuration work anymore but becomes productive and a way to automate repetitive tasks, quickly deploy applications and proactively manage servers onsite or in […]

Schade, dass dir der Artikel nicht gefallen hat.
Was sollten wir deiner Meinung nach besser machen?

Thank you for your feedback!
We will get back to you as soon as the article is finished.

├ťbrigens: kennst du schon unser Tutorial zum Thema Install WordPress on Ubuntu or Debian?



Get the latest gridscale developer tutorials here.
And donÔÇÖt worry - we wonÔÇÖt spam you