Foreman Headerbild
inovex

Foreman Provision: A Comfortable Resource Management Tool for Foreman

Lesezeit
3 ​​min

Notice:
This post is older than 5 years – the content might be outdated.

At inovex we use open source technology on a daily basis and try to give back to the community in return. One great example is the Foreman Provision project that was initially created by my co-worker Nils Domrose in co-operation with our customer Filiadata GmbH, the IT service provider for German company dm-drogerie markt GmbH + Co. KG. Foreman Provision is a comfortable wrapper that uses the Foreman REST API to create and manage resources in Foreman. Filiadata has published the Foreman Provision tool on Github under the terms and conditions of the MIT license which allows it to be enhanced and used by the public. Let’s take a look at the technical details of this project!

Getting Started with Foreman Provision

Foreman Provision is a Ruby Gem available on Github. One of its few dependencies is the official Foreman API Ruby Gem. After you’ve entered your Foreman user credentials you are ready to start using the Foreman Provision Gem in your Ruby project or creating configuration files that describe the resources you want to manage. At the time of writing Foreman 1.8.0 is the latest stable version. We will use it along with the latest Foreman Provision source code (master branch).

Right now there are no hosts in Foreman. We’ll use Foreman Provision to add some automatically.

Set the Foreman Provision authentication credentials that will be used to log into Foreman. You can find the OAuth credentials in the Foreman Settings tab:

OAuth Settings

Let’s get to the interesting part, the file that describes our services. You can find examples in the examples/  directory of your repository clone. We’ll use the following config:

Here we define four arrays: subnets, domains, hostgroups and hosts. Each of them expects a minimum list of attributes. Hosts for example make use of hostgroups that define attributes on a higher abstraction level. Hosts that are added to the hostgroup Test-Hosts run the operating system CentOS 7.0, have an IP address in the subnet named default, will be added to the production environment and much more.

Simply copy & paste this YAML-formatted data into the file conf/config.yaml. We’ll execute the tool in test mode first to see what it does.

Looks great, now fire up those commands in god mode! 🙂

That was easy! What happens when we execute this again?

Right, the tool recognizes the existence of these resources and simply skips creation. Now we see that hosts appear in the Foreman UI:

Foreman Hosts Added

 

Foreman Host Details

Now these hosts will PXE boot over the network, install an operating system on hard disk and after booting for the first time tools like SaltStack, Rex or Puppet will take care of installing and configuring additional software that makes your new hosts ready to use in production.

You can also use compute resources like KVM/vsphere to deploy VMs in your virtual infrastructure. See the  examples/ directory for some examples.

Want to learn more about Foreman? Take a look at our slides and videos of the talks we give at various events.

3 Kommentare

Hat dir der Beitrag gefallen?

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert