CFEngine Build System version 2

June 14, 2022

A while back we released version 2 of cfbs, and even though we release versions of this tool quite frequently, without announcing it on the blog, we thought this was a good opportunity to talk a bit about the tool, what’s new and our direction with it in the future. The reason why we called this the “2.0” release is that we are trying to follow semantic versioning, and there were some big new features in the release which could be considered breaking changes.

Philosophy

The cfbs command line tool is responsible for 2 main tasks:

  1. Editing CFEngine Build projects (adding modules, policy files, updating etc.)
  2. Building a project into a ready to deploy policy set

An important distinction here is that we imagine the first part, working with projects, is mainly something users will be doing, manually. The second part, building policy for deployment, is often done in automation, you can have scripts running git clone ; cfbs build on your hub or as part of your CI/CD pipeline.

The build command

Since users are building scripts and automation around cfbs build we want this command to be non-interactive and backwards compatible. We will try our very best to not break your policy builds by changing the behavior here, and if we have to at some point, we will communicate it widely.

Other commands

The other commands (init, add, update, remove) we expect users to be running from a terminal, and we want them to be as easy to use as possible, especially for new users and as we add more functionality. This means we are changing them a bit more than the build command, and in many cases making them have interactive prompts to guide users to achieving what they want. Backwards compatibility is not our primary focus here. So, if you intend to build scripts or tests or automation that use these commands, just be aware that they might change in the future. That being said, we are using these commands inside tests and upcoming functionality internally, so we won’t be changing them without good reasons.

What’s new in version 2+

As mentioned before, we release quite frequently, and are already at version 2.2.2. So, instead of focusing on exactly what was added between 1.3.3 and 2.0.0, we’d just like to highlight some of the biggest improvements we made in the last months.

Release numbers and matching versions from outside of CFEngine Build

It is now possible for modules like masterfiles and SURF CFEngine Library to follow their existing versioning, and if they need to make small changes and module releases between versions, they can add a release number at the end of their version number (-1, -2, -3):

Interactive prompts

As hinted at above, we want many of cfbs’s commands to be interactive and help the user with what they need:

$ cfbs init
Please enter name of this CFBS repository [Example]: My new project
Please enter description of this CFBS repository [Example description]: Just an example for the blog post

In all of the prompts you can keep pressing enter to use the defaults, and we try to pick defaults that make sense for most users, especially new ones. Currently, the prompts are quite basic, but in the future we’d like to add more interactivity like choosing between different options using the arrow keys, as an example.

Helping users add masterfiles

Most users will want to add masterfiles as their first module, especially new users. This module contains the default policy that is probably already running on their hub, and which does many important things for CFEngine and CFEngine Enterprise to work as expected. Previously we had a log message which told the user to run cfbs add masterfiles. Now that has been changed to a prompt, and by default, if you press enter, it will be added:

Do you wish to build on top of the default policy set, masterfiles? (Recommended) [YES/y/no/n]: y
Added module: masterfiles

Git commits

The commands you use to edit your project (cfbs.json) now make git commits by default. This allows you to easily track the changes made to your project and push them to a remote git repository.

$ cfbs add autorun
Added module: autorun
The default commit message is 'Added module 'autorun'' - edit it? [yes/y/NO/n]
Committing using git:

[main 9403c3c] Added module 'autorun'
 1 file changed, 12 insertions(+)

$

To disable this functionality, you can answer no to the question about using git in cfbs init, or set "git": false in your cfbs.json.

Specify versions

If there is a problem with the latest version of a module, you can now easily look through the other versions on the website and add the one you want:

$ cfbs add promise-type-git@0.1.0

A sneak peek

Without revealing too much, here is a sneak peek of what comes next:

Get in touch with us
to discuss how we can help!
Contact us
Sign up for
our newsletter
By signing up, you agree to your email address being stored and used to receive newsletters about CFEngine. We use tracking in our newsletter emails to improve our marketing content.