REST API for Nova

Posted by Mahesh Kumar
February 20, 2012

One feature our customers have requested for the next version of CFEngine Nova (available before summer 2012) is having the ability to collect reported data through a REST API. It is already possible to get at reporting data through the Mission Portal web-interface, as well as the command-line client cf-report. However, as we want to provide our customers with greater flexibility, we are now introducing the addition of REST (HTTP) as another interface.

REST-based APIs are convenient for a number of reasons. First, they are commonplace in the industry and many people already know how they work. Secondly, they may integrate more easily with other tools that can call HTTP interfaces.

In our first release of the REST API, we provide most of the reporting data available in the Mission Portal in read-only mode. Included are:

  • Class usage reports.
  • Basic information about hosts and when they were last seen.
  • Promise logs, summaries and compliance status.
  • Running setuid programs.
  • Installed software.
  • State of variables at hosts.
  • File changes and diffs.

The API is versioned so that it may be extended or changed in the future based on customer feedback. It currently supports JSON as its message format.

To get an idea of what you might use the REST API for, suppose you wanted transfer information about promises not kept from Nova into some third-party reporting system. You could use an ETL tool like Pentaho Kettle to automate this process. Let’s set up a simple transformation pipeline. No coding required!

  1. First, extract the data from the Nova REST API using an HTTP input loader.
  2. Next, transform the data using a JSON input step and select the relevant fields. Alternatively, we could use a Javascript transformation for more fine-grained control.
  3. Finally, push the resulting JSON document using an HTTP post step with the url of the third-party reporting service.

REST API in CFEngine 3
Nova

While this example is simple, it is possible to use Pentaho Kettle to combine several results from the REST API to make custom reports, as well as converting the data to different formats and write the output to multiple places.

We hope that you will find the REST API a useful addition to Nova and that it will provide a another avenue for integrating CFEngine with your existing infrastructure. Let us know how we can improve!