Nick has been asked several times how he develops CFEngine policy using AI, so for episode 67 he did it live. He used an isolated environment with a hub running a 3.29 nightly, two clients, and a Build project the hub syncs from git. Claude Code only had the cfengine-policy and mission-portal skills from cfengine-skills and a Mission Portal login. On first use the skill pulls down the CFEngine documentation for the installed version and uses it as context.
He wanted to write some policy that surfaces information CFEngine is already collecting. cf-monitord measures values like load, CPU, network traffic and log volume over time, and when those deviate from the norm it defines classes like loadavg_high_dev2 or cpu_high_anomaly. Those classes are not tagged for inventory or reporting so they don’t reach the hub, and by default only the hub sends its own measurements.
Nick asked Claude to make a plan for policy that inventories and reports on abnormal behavior. The first plan also published the values of each abnormal observable as inventory. Inventory isn’t designed for things that constantly change. Each change is a delta the hub has to collect, multiply that across a fleet and you get a lot of database work. Nick pushed back (Claude said he was right to) so that measured values aren’t reported separately and inventory only things that change less frequently. Nick is also not a fan of autorun, so the bundle runs explicitly.
The policy Claude wrote is added with cfbs, which puts the monitoring_anomalies bundle in control_common_bundlesequence_end. Settings can be adjusted in def.json and overridden for a policy set or with host specific data. When an observable is 2 or 3 standard deviations from normal the bundle defines a persistent class that lasts 60 minutes by default. Inventory attributes show the host’s status (normal, deviation or anomaly) and which observables are abnormal. def.json also sets default_data_select_host_monitoring_include so the hub collects measurements from all hosts, and you can see the values in the Measurements app.
After committing and pushing, the hub picked up the change. host002 reported normal and the hub had a few CPU anomalies. Nick started two scripts that act like malware, a miner on host001 and one that tries to SSH and spread from host002, let them run for a few minutes and asked Claude what was causing the anomaly on host001. Claude could not confirm the cause from the data on the hub. It pointed out that the new def.json enabled mpf_augments_control_enabled, which restarted cf-serverd and cf-monitord on each host, and the anomalies (syslog_high and mem_cached_high) showed up right after that. It suggested a journalctl command to run on host001 to check.
Claude didn’t have enough information to really diagnose the miner. Maybe we continue on for Christmas and write some generic indicator of compromise policy so we get a better diagnosis next time.
Video
The video recording is available on YouTube:
There was no after-show chat this time, I was busy eating turkey. Usually, at the end of every webinar, we stop the recording for a nice and relaxed, off-the-record chat with attendees. Join the next webinar to not miss this discussion.
Links
- Connect w/ Nick, Cody, Craig, or Herman
- cfengine-skills (CFEngine skills for Claude Code and other AI agents)
- cf-monitord docs
- Measurements app docs
- Masterfiles Policy Framework docs
- All Episodes