Introduction
CFEngine is a free and open source configuration management system that provides a framework for automatically managing an IT infrastructure. It is possible to automate configuration and maintenance of a large number of computer desktops, servers, network devices, and smartphones easily using CFEngine. CFEngine is quite similar to Puppet or Chef, but it has a very small footprint. It is written in the C programming language, so it is very fast.
Here, we will learn how to install CFEngine on an Ubuntu 16.04 server.
Prerequisites
- A newly deployed Vultr Ubuntu 16.04 server instance.
- A non-root user with sudo privileges setup on your server.
Step 1: Update the system
Before starting, you will need to update the system’s package repository database with the latest version. You can do this with the following command:
sudo apt-get update -y
sudo apt-get upgrade -y
Once your system is up to date, you can proceed to the next step.
Step 2: Install CFEngine
By default, CFEngine is not available in the Ubuntu 16.04 repository. So you will need to add CFEngine’s package repositories to your server’s repository list. You can do this by running the following command:
sudo nano /etc/apt/sources.list
When the text editor opens, add the following lines:
deb http://cfengine.com/pub/apt/packages stable main
Save the file when you are finished.
Next, you will need to download CFEngine’s public key. You can download it with the following command:
wget http://cfengine.com/pub/gpg.key
Add apt-key to the list of trusted keys.
sudo apt-key add gpg.key
Next, update the apt package repository with the following command:
sudo apt-get update -y
Once the repository has been updated, install CFEngine Community Edition by running the following command:
sudo apt-get install cfengine-community
You can check the version of CFEngine with the following command:
cf-agent -V
You should see the following output:
CFEngine Core 3.10.0
Step 3: Bootstrap the host to the policy server
You will need to start CFEngine’s policy hub in order to establish a connection between the host and the policy server. You can do this by bootstrapping it with your server’s IP address.
sudo cf-agent --bootstrap your-server-ip
CFEngine is now ready to be used.
Step 4: Create your first policy
You will need to create a policy file in order to automate a system administration task. For example, create a new file called policy.cf
:
sudo nano /opt/policy.cf
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
reports:
cfengine_3::
"My First Policy";
}
Save and close the file when you are finished, then run the policy with the following command:
sudo cf-agent policy.cf
You should see the following output:
My First Policy
Congratulations! You have successfully installed CFEngine on Ubuntu 16.04 server.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article