Chapter 21. Example: Remedying Resource Drift

Maintain servers, particularly production or business critical servers and applications, requires keeping rein on the configuration files and packages on those systems. When an unexpected change occurs, the system moves away from the administrator-defined state. That is configuration drift.
JBoss ON can monitor configuration files and target directories and track any changes to those area. This uses a drift definition which sets where the JBoss ON agent monitors configuration and at what frequency. If drift is detected, then the JBoss ON server can fire an alert and run an alert CLI script that reverts, or remedies, the changed configuration files.

21.1. The Plan for the Scripts

There are two different scripts in play because there are two different sets of situations for managing drift:
  • First, there is a script to set up drift for a resource. This shell script runs through a series of setup steps at once:
    1. It creates the drift definition for a resource (through the driftDef.js CLI script).
    2. It creates a generic deploy.xml recipe, zips the drift directory, and creates a new bundle and bundle deployment (through the createBundle.js CLI script).
    3. After waiting for the initial snapshot, it then pins the snapshot to the definition (through the snapshot.js CLI script).
    All of those files are generated by the shell script.
  • An alert definition has to be created through the UI (not the CLI), but it can be configured to use any drift detection as a condition and then to run a server-side script in response. This second script simply deploys the bundle that was made of the pristine base directory and overwrites the drift.