Install and Configure Foreman 3.x on Debian 11/ Debian 10

Posted on 148 views

Manual Infrastructure management is now a thing of the past. It is hard to scale, troubleshoot and perform deep integration with existing enterprise Infrastructure. Foreman is an open source tool created to help System Administrators automate provisioning, configuration of IT systems. With Foreman you can actually automate complete System’s Lifecycle. This guide will walk you through the steps to install and configure Foreman 3.x on Debian 11/ Debian 10 Linux.

With Chef, Puppet, Salt, Ansible and Foreman’s smart proxy architecture, Foreman can easily automate repetitive tasks, quickly deploy applications, and proactively manage change, both on-premise with VMs and bare-metal or in the cloud.

For Ubuntu: Install Foreman on Ubuntu Linux

Foreman Architecture:

foreman_architecture

With Foreman you can:

  • Discover, provision and upgrade your entire bare-metal infrastructure
  • Create and manage instances in virtualization environment and across private and public clouds
  • Install operating systems via PXE, local media or from templates or images
  • Control and gather reports from your configuration management software
  • Group your hosts and manage them in bulk, regardless of location
  • Review historical changes for auditing or troubleshooting
  • Web user interface, JSON REST API and CLI for Linux
  • Extend as needed via a robust plugin architecture

Foreman, provides comprehensive, interaction facilities including a web frontend, CLI and RESTful API which enables you to build higher level business logic on top of a solid foundation. It is deployed in many organizations, managing from 10s to 10,000s of servers. Several commercial products are based on Foreman.

Install Foreman 3.x on Debian 11/ Debian 10

We’ll use Foreman installer which is a collection of Puppet modules that installs everything required for a full working Foreman setup. This installer uses native OS packaging, both for Debian based and Red Hat based systems.

Step 1: Update System

We always start our installation by ensuring the system is updated.

sudo apt update
sudo apt get -y upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f

After the system is rebooted, you can continue to step 2.

Step 2: Add Puppet and Foreman Repositories

Next we need to add all the repositories that will be required for both dependencies and actual Foreman package installation.

Install dependency packages:

sudo apt update
sudo apt -y install curl wget ca-certificates wget lsb-release gpg ca-certificates

Add repositories to Debian 11 (Bullseye)

Add Puppet repositories:

wget https://apt.puppet.com/puppet6-release-bullseye.deb
sudo dpkg -i puppet6-release-bullseye.deb

Add Foreman repositories:

echo "deb http://deb.theforeman.org/ bullseye nightly" | sudo tee /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins nightly" | sudo tee -a /etc/apt/sources.list.d/foreman.list

Add repositories to Debian 10 (Buster)

wget https://apt.puppet.com/puppet6-release-buster.deb
sudo dpkg -i ./puppet6-release-buster.deb

Add Foreman repositories.

echo "deb http://deb.theforeman.org/ buster nightly" | sudo tee /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins nightly" | sudo tee -a /etc/apt/sources.list.d/foreman.list

Then import repository GPG key

### Debin 11 (Bullseye) ###
curl -fsSL https://deb.theforeman.org/pubkey.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/foreman.gpg

### Debian 10 (Buster)
wget -q https://deb.theforeman.org/pubkey.gpg -O- | sudo apt-key add -

Step 3: Download Foreman installer on Debian 11/ Debian 10

Downloading the installer with the command below.

sudo apt update
sudo apt install foreman-installer

Hit the key to proceed with the installation:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  fonts-lato libjs-jquery libruby2.7 puppet-agent rake ruby ruby-ansi ruby-clamp ruby-hashie ruby-highline ruby-kafo ruby-kafo-parsers ruby-kafo-wizards ruby-little-plugger ruby-logging
  ruby-minitest ruby-multi-json ruby-net-telnet ruby-oj ruby-power-assert ruby-powerbar ruby-rubygems ruby-test-unit ruby-xmlrpc ruby2.7 rubygems-integration zip
Suggested packages:
  ri ruby-dev ruby-activesupport bundler
The following NEW packages will be installed:
  fonts-lato foreman-installer libjs-jquery libruby2.7 puppet-agent rake ruby ruby-ansi ruby-clamp ruby-hashie ruby-highline ruby-kafo ruby-kafo-parsers ruby-kafo-wizards ruby-little-plugger
  ruby-logging ruby-minitest ruby-multi-json ruby-net-telnet ruby-oj ruby-power-assert ruby-powerbar ruby-rubygems ruby-test-unit ruby-xmlrpc ruby2.7 rubygems-integration zip
0 upgraded, 28 newly installed, 0 to remove and 55 not upgraded.
Need to get 32.6 MB of archives.
After this operation, 186 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Before using the installer to get the latest release of Foreman running onDebian 11/ Debian 10 machine, remove the entry on /etc/hosts for localhost.

$ ip ad
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3:  mtu 1450 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:a8:47:e1 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 172.10.10.149/24 brd 172.10.10.255 scope global dynamic ens3
       valid_lft 78629sec preferred_lft 78629sec
    inet6 fe80::f816:3eff:fea8:47e1/64 scope link
       valid_lft forever preferred_lft forever

$ sudo vim /etc/hosts
172.10.10.149 foreman.example.com foreman

Set hostname using hostnamectl command:

sudo hostnamectl set-hostname foreman.example.com --static

Edit /etc/hosts and add IP and hostname

$ sudo vim /etc/hosts
172.10.10.149 foreman.example.com

Test to confirm hostname doesn’t return the localhost address.

$ ping $(hostname -f)
PING foreman.example.com (172.10.10.149) 56(84) bytes of data.
64 bytes from foreman.example.com (172.10.10.149): icmp_seq=1 ttl=64 time=0.015 ms
64 bytes from foreman.example.com (172.10.10.149): icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from foreman.example.com (172.10.10.149): icmp_seq=3 ttl=64 time=0.031 ms

--- foreman.example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2036ms
rtt min/avg/max/mdev = 0.015/0.026/0.033/0.008 ms

Step 4: Install Foreman on Debian 11 / Debian 10

By default the installation will run is non-interactive mode, but the configuration can be customized by supplying any of the options listed in:

sudo foreman-installer --help

For interactive mode, run:

sudo foreman-installer -i

The wizard will gather all required information, when ready to start press y.

Welcome to the Foreman installer!
---------------------------------

This wizard will gather all required information. You can change any parameter
to your needs.


Ready to start? (y/n)
y

Enable all the modules you want installed.

...
Main Config Menu
1. [✓] Configure foreman
2. [✓] Configure foreman_cli
3. [✗] Configure foreman_cli_ansible
4. [✗] Configure foreman_cli_azure
5. [✗] Configure foreman_cli_discovery
6. [✗] Configure foreman_cli_kubevirt
7. [✗] Configure foreman_cli_openscap
8. [✓] Configure foreman_cli_puppet
9. [✗] Configure foreman_cli_remote_execution
10. [✗] Configure foreman_cli_tasks
11. [✗] Configure foreman_cli_templates
12. [✗] Configure foreman_cli_webhooks
13. [✓] Configure foreman_proxy
14. [✓] Configure puppet
15. [✗] Configure foreman_plugin_acd
16. [✗] Configure foreman_plugin_ansible
17. [✗] Configure foreman_plugin_azure
18. [✗] Configure foreman_plugin_bootdisk
19. [✗] Configure foreman_plugin_chef
20. [✗] Configure foreman_plugin_column_view
21. [✗] Configure foreman_plugin_default_hostgroup
22. [✗] Configure foreman_plugin_dhcp_browser
23. [✗] Configure foreman_plugin_discovery
24. [✗] Configure foreman_plugin_expire_hosts
25. [✗] Configure foreman_plugin_hooks
26. [✗] Configure foreman_plugin_host_extra_validator
27. [✗] Configure foreman_plugin_host_reports
28. [✗] Configure foreman_plugin_kubevirt
29. [✗] Configure foreman_plugin_leapp
30. [✗] Configure foreman_plugin_memcache
31. [✗] Configure foreman_plugin_monitoring
32. [✗] Configure foreman_plugin_omaha
33. [✗] Configure foreman_plugin_openscap
34. [✗] Configure foreman_plugin_ovirt_provision
35. [✓] Configure foreman_plugin_puppet
36. [✗] Configure foreman_plugin_puppetdb
37. [✗] Configure foreman_plugin_remote_execution
38. [✗] Configure foreman_plugin_remote_execution_cockpit
39. [✗] Configure foreman_plugin_salt
40. [✗] Configure foreman_plugin_setup
41. [✗] Configure foreman_plugin_snapshot_management
42. [✗] Configure foreman_plugin_statistics
43. [✗] Configure foreman_plugin_tasks
44. [✗] Configure foreman_plugin_templates
45. [✗] Configure foreman_plugin_webhooks
46. [✗] Configure foreman_compute_ec2
47. [✗] Configure foreman_compute_gce
48. [✗] Configure foreman_compute_libvirt
49. [✗] Configure foreman_compute_openstack
50. [✗] Configure foreman_compute_ovirt
51. [✗] Configure foreman_compute_vmware
52. [✗] Configure foreman_proxy_plugin_acd
53. [✗] Configure foreman_proxy_plugin_ansible
54. [✗] Configure foreman_proxy_plugin_chef
55. [✗] Configure foreman_proxy_plugin_dhcp_infoblox
56. [✗] Configure foreman_proxy_plugin_dhcp_remote_isc
57. [✗] Configure foreman_proxy_plugin_discovery
58. [✗] Configure foreman_proxy_plugin_dns_infoblox
59. [✗] Configure foreman_proxy_plugin_dns_powerdns
60. [✗] Configure foreman_proxy_plugin_dynflow

-- press enter/return to continue or q to stop --
61. [✗] Configure foreman_proxy_plugin_monitoring
62. [✗] Configure foreman_proxy_plugin_omaha
63. [✗] Configure foreman_proxy_plugin_openscap
64. [✗] Configure foreman_proxy_plugin_remote_execution_ssh
65. [✗] Configure foreman_proxy_plugin_reports
66. [✗] Configure foreman_proxy_plugin_salt
67. [✗] Configure foreman_proxy_plugin_shellhooks
68. Display current config
69. Save and run
70. Cancel run without Saving

Example to enable libvirt module:

?  48
Module foreman_compute_libvirt configuration
1. Enable/disable foreman_compute_libvirt module, current value: false
2. Back to main menu
Choose an option from the menu... 1
Enable foreman_compute_libvirt module? (y/n) y

Module foreman_compute_libvirt configuration
1. Enable/disable foreman_compute_libvirt module, current value: true
2. Configure Advanced parameters
3. Reset a parameter to its default value
4. Back to main menu
Choose an option from the menu... 4

Once done use 69. Save and run

Choose an option from the menu... 69

More examples are given in the Installation Options section. Adding -v will disable the progress bar and display all changes.

You can also start the Foreman installer without interactive mode:

sudo foreman-installer

If Smart Proxy, Puppet master are installed along Foreman, the installer will output details about them after the installation.

Preparing installation Done                                              
  Success!
  * Foreman is running at https://deb10.novalocal
      Initial credentials are admin / yafNTaFNNJRUGP84
  * Foreman Proxy is running at https://deb10.novalocal:8443
  The full log is at /var/log/foreman-installer/foreman.log

Use the details given in the output to login to Foreman Dashboard.

Install-foreman-debian-10-linux-01-1024x610

You should see a dashboard which looks similar to below.

Install-foreman-debian-10-linux-02-1024x501

You’re now on the right path to defining Infrastructure automation with Foreman.

install-foreman-ubuntu-18.04-02-min

Reference and more reading:

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.