Configuration and change management with Bcfg2
Reporting
In the third and final phase, the client generates a report containing the system status and other details, including the number of correct and incorrect configuration entries and the number of non-managed objects on the system. The client sends this message to the server, which then processes it to create web pages, RSS feeds, and emails.
The core of any Bcfg2 system is the configuration specification. Administrators use it to describe the target configurations for the systems they manage. This process occurs in two stages: Bcfg2 refers to the structure looked at earlier, as well as the profiles, groups, and bundles it contains as metadata. The metadata define the elements that Bcfg2 needs to configure for a client.
When a client sends a request to a server, the server generates the abstract configuration from the matching metadata (see Figure 2). This template contains all the required configuration entries for the target system, but without any content. For example, a ConfigFile element contains a file name, but not the file content.
Generators
After the server has created the framework of the configuration, it uses generators to bind tangible information to each entry. Bcfg2 uses a number of generators written in Python.
The administrator needs to enable generators in the /etc/bcfg2.conf file. A typical installaton would at least use
generators = Cfg, Pkgmgr, Rules, TCheetah
Each registered generator is capable of instantiating a number of configuration elements.
In simple cases, the Cfg generator will return a static file, and in more complex cases, a TCheetah generator will use a template and script language to retrieve the file content from a database entry. Other generators handle configuration elements, such as services and packages. Consequently, Bcfg2 is capable of using almost any data source to compile a tangible configuration (see Figure 3).
Cfg
The Cfg plugin mainly generates content for ConfigFile-type entries. To configure an element, the administrator creates a subdirectory below Cfg in the repository with the same name as the corresponding bundle. Then you create a static file in the directory and let Bcfg2 distribute the file to all your clients.
To define the target clients, you can add suffixes to file names. The H_Hostname suffix distributes the file to the specified machines only; GPrio_Group sends the file to all systems that have the specified group profile. If a host belongs to multiple groups, Bcfg2 applies the highest priority file.
An :info file in the same directory defines permissions, with entries like:
owner: root group: admin perms: 0644
Also, you can specify values such as the file encoding or the behavior for local changes. The functionality provided by the Cfg generator helps you manage a major part of the system; however, it does not always offer the flexibility required to manage large-scale systems.
To manage large networks, the Bcfg2 developers created the TCheetah generator, based on the Cheetah template language [7]. Cheetah supports instructions that range from simple string operations, to flow control, to Python code embedded directly in configuration files.
TCheetah adopts the Cfg generator's directory structure with directories below /var/lib/bcfg2/TCheetah representing the configuration elements. Each directory contains an info file with the same content as the Cfg generator, along with a template configuration. Cheetah code, which can contain some Bcfg2-specific extensions, is then added. Dropping Listing 4 into /var/lib/bcfg2/TCheetah/etc/motd/template would create a dynamic message of the day. The TCheetah Generator replaces $self.metadata.hostname with the actual values and then runs the loop that starts with #for.
Listing 4
Script for an Automatic motd
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.