These instructions describe how to download and install the latest version of CFEngine Community using pre-compiled rpm and deb packages for Ubuntu, Debian, Redhat, CentOS, and SUSE.
It also provides instructions for the following:
Tutorials, recommended reading. and production environment recommendations appear at the end of this page.
Please Note: Internet access is required from the host if you wish to use the quick install script.
Use the following script to install CFEngine on your 32- or 64-bit machine.
$ wget -O- http://cfengine.package-repos.s3.amazonaws.com/quickinstall/quick-install-cfengine-community.sh | sudo bash
$ sudo /var/cfengine/bin/cf-agent --bootstrap <IP address of policy server>
If you require more details on bootstrapping, review Step 3 below. Bootstrapping completes the installation.Select the package to download that matches your operating system. This stores the cfengine-community3.6.1-1* file onto your machine.
Redhat/CentOS/SUSE 64-bit:
$ wget http://cfengine.package-repos.s3.amazonaws.com/community_binaries/cfengine-community-3.6.1-1.x86_64.rpm
Redhat/CentOS/SUSE 32-bit:
$ wget http://cfengine.package-repos.s3.amazonaws.com/community_binaries/cfengine-community-3.6.1-1.i386.rpm
Ubuntu/Debian 64-bit:
$ wget http://cfengine.package-repos.s3.amazonaws.com/community_binaries/cfengine-community_3.6.1-1_amd64.deb
Ubuntu/Debian 32-bit:
$ wget http://cfengine.package-repos.s3.amazonaws.com/community_binaries/cfengine-community_3.6.1-1_i386.deb
Install the package on a machine designated as a Policy Server. A Policy Server is a CFEngine instance that contains promises (business policy) that get deployed to Hosts. Hosts are instances (clients) that retrieve and execute promises.
Choose the right command for your operating system:
Redhat/CentOS/SUSE 64-bit:
$ sudo rpm -i cfengine-community-3.6.1-1.x86_64.rpm
Redhat/CentOS/SUSE 32-bit:
$ sudo rpm -i cfengine-community_3.6.1-1.i386.rpm
Ubuntu/Debian 64-bit:
$ sudo dpkg -i cfengine-community_3.6.1-1_amd64.deb
Ubuntu/Debian 32-bit:
$ sudo dpkg -i cfengine-community_3.6.1-1_i386.deb
Note: You might get a message like this: “Policy is not found in /var/cfengine/inputs, not starting CFEngine.” Do not worry; this is taken care of during the bootstrapping process.
The Policy Server must be bootstrapped to itself. Find the IP address of your Policy Server (type $ ifconfig).
Run the bootstrap command:
$ sudo /var/cfengine/bin/cf-agent --bootstrap <IP address of policy server>
Example: $ sudo /var/cfengine/bin/cf-agent –bootstrap 192.168.1.12
Upon successful completion, a confirmation message appears: “Bootstrap to ‘192.168.1.12’ completed successfully!”
Type the following to check which version of CFEngine your are running:
$ /var/cfengine/bin/cf-promises --version
The Policy Server is installed.
As stated earlier, Hosts are instances that retrieve and execute promises from the Policy Server. Install a package on your Host. Use the same package you installed on the Policy Server in Step 2. Note that you must have access to at least one more VM or server and it must be on the same network as the Policy Server that you just installed.
The Host(s) must be bootstrapped to the Policy Server in order to establish a connection between the Host and the Policy Server. Run the same commands that you ran in Step 3.
$ sudo /var/cfengine/bin/cf-agent --bootstrap <IP address of policy server>
Example: $ sudo /var/cfengine/bin/cf-agent –bootstrap 192.168.1.12
The CFEngine installation process is complete.
Step 1. Create a file called hello_world.cf and add the following content:
```cf3 body common control { bundlesequence => { “test” }; }
bundle agent test { reports: # This is a promise type.
cfengine_3:: # This means the promise will only
# be kept on a CFEngine_3 system.
"Hello World"; # This is a simple promise; it generates a report
# that says "Hello world".
} ```
Step 2. Run the policy:
$ sudo /var/cfengine/bin/cf-agent hello_world.cf
The policy displays the following output:
R: Hello world
Find more policy examples in the [Examples section][Examples and Tutorials].
Create a policy that ensures (promises) that a file called example.txt will always exist on the Host.
Step 1. On the Policy Server, create a file called mypolicy.cf and add it to the /var/cfengine/masterfiles directory:
$ sudo <editor> /var/cfengine/masterfiles/mypolicy.cf
Step 2. Add the following lines to the file:
```cf3 bundle agent example { files: cfengine3:: # This is a class context (the promise will only # be kept on a CFEngine3 system)
“/home/vagrant/example.txt” # Path and name of the file we wish to ensure exists create => “true”; # Make sure the file exists; create if it does not } ```
Step 3. Update /var/cfengine/masterfiles/promises.cf to include this new policy. To do so, modify the promises.cf file to ensure that (1 the mypolicy.cf file is being included in the next policy distribution and that (2 example is in the bundlesequence.
$ sudo <editor> /var/cfengine/masterfiles/promises.cf
```cf3 … bundlesequence => { # Common bundles first for best practice “def”, “example”, …
inputs => {
# Global common bundles
"def.cf",
"mypolicy.cf", ... ``` The process is complete. The next time CFEngine runs on the Host (which by default is every 5 minutes), it will pull down the latest policy update and ensure that the **example.txt** file exists (this is the desired state). In fact, any Host that has installed CFEngine will contain the **example.txt** file (because we defined the cfengine_3:: class above).
If you plan to use Community in a production environment, complete the following general requirements:
Host(s) Memory
256 MB available memory in order to run the CFEngine agent software (cf-agent).
Disk Storage
A full installation of CFEngine requires 25 MB. Additional disk usage depends on your specific policies, especially those that concern reporting.
Network
Verify that the machine’s network connection is working and that port 5308 (used by CFEngine) is open for both incoming and outgoing connections.
If iptables are active on your operating system, stop this service or adapt
it to allow for communication on the above ports. If applicable, type the
following two commands: /etc/init.d/iptables stop and chkconfig iptables
off
Everyone is a first-time user a some point. We want to make the CFEngine Enterprise installation process easy for all of our new users. Before you forget your first-time experience, we would love for you to let us know how we can improve on this process.