How to Install CFEngine Community on Ubuntu 26.04
Install CFEngine Community on Ubuntu 26.04 or 24.04, bootstrap a policy server and a managed host, and roll out a first policy.
CFEngine is a lightweight configuration management system written in C: a small agent on every machine fetches policy from a policy server and keeps the machine in the state that policy describes. This guide installs CFEngine Community from the project's apt repository on Ubuntu 26.04 LTS, bootstraps a policy server, connects a second host to it and distributes a first policy. The steps are identical on Ubuntu 24.04 LTS. Ubuntu 16.04 left standard support in 2021 and should not be used for new installations.
Requirements
- One Ubuntu 26.04 server that will be the policy server (example address
203.0.113.10) and, optionally, further hosts to manage (example203.0.113.20). - A user with
sudorights on each machine. - TCP port 5308 on the policy server reachable from the managed hosts.
If the machines have private addresses on a shared network, use those for everything below. CFEngine identifies hosts by IP address and key, so the addresses act as an allowlist.
Step 1: Add the CFEngine repository
Run this step and the next on the policy server and on every host you want to manage. Download the signing key and display its fingerprint:
wget -q -O cfengine.asc https://cfengine-package-repos.s3.amazonaws.com/pub/gpg.key
gpg --show-key --with-fingerprint ./cfengine.asc
The fingerprint must match the one published on the CFEngine site:
F2EE 2A0E 76A6 D469 8AE5 301A 7420 C142 9B92 0A5E
If it does, install the key and add the repository:
sudo mv ./cfengine.asc /etc/apt/trusted.gpg.d/
echo "deb https://cfengine-package-repos.s3.amazonaws.com/pub/apt/packages stable main" | sudo tee /etc/apt/sources.list.d/cfengine-community.list
Older tutorials use apt-key add and edit /etc/apt/sources.list directly. apt-key is gone from current Ubuntu releases; the commands above are the ones CFEngine documents now.
Step 2: Install CFEngine Community
sudo apt-get update
sudo apt-get install -y cfengine-community
This installs the newest release in the repository (3.29.0 in November 2026). The current long-term support series is 3.27. If you prefer to stay on it, list the available versions and install one explicitly:
apt-cache madison cfengine-community
sudo apt-get install -y cfengine-community=3.27.3-1.debian12
Everything is installed under /var/cfengine, with the programs in /var/cfengine/bin. Confirm the version:
/var/cfengine/bin/cf-promises --version
A message that policy was not found in /var/cfengine/inputs during installation is expected. Bootstrapping fixes it.
Step 3: Bootstrap the policy server
The policy server bootstraps to its own address. On 203.0.113.10:
sudo /var/cfengine/bin/cf-agent --bootstrap 203.0.113.10
The command ends with Bootstrap to '203.0.113.10' completed successfully!. From this point the CFEngine daemons run on the machine, and the policy it serves lives in /var/cfengine/masterfiles.
If UFW is active on the policy server, allow your managed hosts to connect (adjust the network to yours):
sudo ufw allow from 203.0.113.0/24 to any port 5308 proto tcp
Step 4: Bootstrap a host to the policy server
On each managed host, after completing steps 1 and 2, point the agent at the policy server:
sudo /var/cfengine/bin/cf-agent --bootstrap 203.0.113.10
The host exchanges keys with the policy server, copies the policy into its own /var/cfengine/inputs and from then on checks for updates about every five minutes.
Step 5: Write and test a first policy
Try a policy locally before distributing it. Create /tmp/example.cf:
nano /tmp/example.cf
bundle agent example
{
files:
linux::
"/tmp/hello-world" create => "true";
}
bundle agent __main__
{
methods:
"example";
}
Check the syntax, run the policy and confirm that the file now exists:
sudo /var/cfengine/bin/cf-promises -f /tmp/example.cf
sudo /var/cfengine/bin/cf-agent -Kf /tmp/example.cf
ls -l /tmp/hello-world
-K ignores the locks that normally stop a promise from being re-evaluated within a minute, and -f names the policy file. Add --verbose to see what the agent decides and why.
Step 6: Distribute the policy to all hosts
On the policy server, copy the file into the masterfiles directory:
sudo cp /tmp/example.cf /var/cfengine/masterfiles/example.cf
Then tell the policy framework to load the file and to run the bundle, using an augments file:
sudo nano /var/cfengine/masterfiles/def.json
{
"inputs": ["example.cf"],
"variables": {
"default:def.control_common_bundlesequence_end": {
"value": ["example"]
}
}
}
Validate the complete policy set before the hosts fetch it:
sudo /var/cfengine/bin/cf-promises -cf /var/cfengine/masterfiles/promises.cf
No output means the policy is valid. Within a few minutes each bootstrapped host copies the new files and creates /tmp/hello-world. To avoid waiting, trigger an update and a run on a host by hand:
sudo /var/cfengine/bin/cf-agent -KIf update.cf
sudo /var/cfengine/bin/cf-agent -KI
After installation
By default the policy framework lets the policy server trust keys from any address so that bootstrapping is easy. Once all your hosts are connected, restrict that with the trustkeysfrom and acl settings described in the Masterfiles Policy Framework reference. Keep your own policy files separate from the files shipped in masterfiles, and put the directory under version control so every change is reviewable.
CFEngine packages are upgraded like any other package with sudo apt-get update && sudo apt-get install cfengine-community. Upgrade the policy server first, then the hosts.
Frequently asked questions
What is the difference between Community and Enterprise?
Community is the GPL-licensed core: the agent, the policy server and the policy language. Enterprise adds the Mission Portal web interface, central reporting and commercial support; CFEngine offers it free of charge for up to 25 hosts. Commercial support only covers Enterprise LTS versions.
Is there a faster way to install on many machines?
Yes. The cf-remote tool (pipx install cf-remote) installs packages over SSH and bootstraps in one command, for example cf-remote --version=3.27.3 install --edition community --clients 203.0.113.20,203.0.113.21 --bootstrap 203.0.113.10.
Bootstrap fails on a host. What should I check?
Confirm that the host can reach TCP port 5308 on the policy server, that you bootstrapped the policy server to itself first, and that you used an address the policy server actually listens on (the private address when both machines share a private network). Running the bootstrap command with --verbose shows where it stops.
Where do I edit policy: masterfiles or inputs?
Always in /var/cfengine/masterfiles on the policy server. /var/cfengine/inputs on every machine is a copy that the agent overwrites on its next update.