Show posts by author:
Nick Anderson

Feature Friday #11: namespaces

Did you know that CFEngine has namespaces? Let’s see how they can facilitate policy sharing while avoiding “duplicate definitions of bundle” errors. Most of the Masterfiles Policy Framework (MPF) and policy examples for CFEngine use the default namespace. However, body file control allows you to specify a namespace that applies for the rest of the file or until it’s set again by another body file control. Let’s consider a contrived example.

Posted by Nick Anderson
May 24, 2024

Feature Friday #10: cf-support

Found a bug, asking for help? Use cf-support to collect info quickly. cf-support was born from interactions supporting Enterprise customers to streamline data collection and was introduced in late 2022 with the release of 3.18.31 and 3.21.02. Furthermore, it was featured on The Agent is In3 episode 21 Troubleshooting with cf-support. It gathers various details about the system and creates an archive that you can attach to your ticket. While its inception was geared towards Enterprise customers, it’s still both useful and available for community users as well.

Posted by Nick Anderson
May 17, 2024

Feature Friday #9: body file control - inputs

Did you know you can include one policy file from another? Traditionally you specify the files you want to make up a policy set using inputs in body common control found in your policy entry ( by default). body common control { # Paths are relative to $(sys.policy_entry_dirname) if not # fully qualified inputs => { "path/to/", "path/to/", }; } body file control lets you specify additional inputs from any file that’s included in the policy and those files can include other files.

Posted by Nick Anderson
May 10, 2024

Feature Friday #8: bundlesequence

Ever want to run just a one or a few select bundles from your policy? While developing policy it’s common to run cf-agent -KI so that you can quickly iterate on changes and the run the policy without locks. But if you are focused on select bundles you may not need the full policy to run, you can use the --bundlesequence option to specify one or more bundles overriding the bundlesequence defined in body common control.

Posted by Nick Anderson
May 3, 2024

Feature Friday #7: depends_on

Ever wanted to make sure a promise only runs if some other promise has succeeded? Consider this contrived example with two reports type promises, It's Friday! and I love CFEngine Feature Friday. Per normal ordering1, these two promises will be emitted in the written order. /tmp/ bundle agent feature_friday { reports: "It's Friday, Friday"; "Gotta get down on Friday"; } command cf-agent --no-lock --bundlesequence feature_friday --file /tmp/ output R: It's Friday!

Posted by Nick Anderson
April 26, 2024

Show notes: The agent is in - Episode 36 - Upgrading to Enterprise

It’s easy to switch from Community to Enterprise. Craig demonstrates the process of migrating from Community to Enterprise and touches on using many of the available components and tools from cf-remote to cf-net and so much in-between. Video The video recording is available on YouTube: 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.

Posted by Nick Anderson
April 25, 2024

Feature Friday #6: cf-promises

Will your policy work? cf-promises can check the CFEngine policy for syntax errors and give you an overview of the host’s context. It’s always a good idea to check your policy for syntax errors. Consider this policy file: /tmp/ bundle agent feature_friday { reports: "$(this.promise_filename)" printfile => cat( "$(this.promise_filename)" ) } Can you spot the error? Let’s see if cf-promises can help: command cf-promises -f /tmp/ output /tmp/ error: syntax error } ^ /tmp/feature-friday-6.

Posted by Nick Anderson
April 19, 2024

Feature Friday #5: cfbs

Do you maintain multiple policy sets? Do you leverage policy written by others? Ever wished for an easier way to upgrade your policy framework? cfbs can help to improve all of these cases. cfbs is a command line tool that aims to help simplify managing a policy set and working with CFEngine Build, a website for finding and sharing modules. A policy set usually - but not always - builds on top of some base, like the Masterfiles Policy Framework (MPF).

Posted by Nick Anderson
April 12, 2024

Feature Friday #4: cf-remote

What’s the easiest way to install cfengine? Have you heard of cf-remote? cf-remote was born out of a developer’s itch for an easy way to get CFEngine installed on some host for testing. We have featured cf-remote in several posts1 since it was first released in 2019, but today is Friday, so let’s review its features. Overview cf-remote (available via the Python Package Index) primarily targets installing CFEngine on a remote host, but it also provides some related conveniences including:

Posted by Nick Anderson
April 5, 2024

Feature Friday #3: execresult_as_data()

When you want to inspect both the return code and output from a command execresult_as_data() might be the function you are searching for. Most CFEngine policy writers have used execresult() and returnszero(). They are useful when you want to do something based on the output of a command or based on its successful execution (returning zero). For example: /tmp/ bundle agent __main__ { vars: "hostname" string => execresult( "$(paths.hostname)", "useshell" ); classes: "my_command_returned_zero" expression => returnszero( "$(paths.

Posted by Nick Anderson
March 29, 2024