Hello CFEngine – CFengine3 on Ubuntu 16.04 Xenial

This article shows you how to install CFEngine 3 on Ubuntu and write a simple “Hello World” program.

Modern configuration management systems let your describe your infrastructure as code in an idempotent way. You define the target state of your computer in text, and the system only makes modifications as needed.

CFEngine is one of the first modern configuration management systems.

Prequisites: command line interface, sudo

Install CFEngine 3

$ sudo apt-get update && sudo apt-get -y install cfengine3

Write Your Policy File

$ nano hello_tero.cf

The contents of hello_tero.cf:

body common control
{
        bundlesequence => { "hello_tero" };
}

bundle agent hello_tero
{
        reports:
                any::
                        "See you in TeroKarvinen.com!";
}

Run

Run (I mean, “activate the bundle”) and see you report:

$ sudo cf-agent --no-lock --file ./hello_tero.cf
R: See you in TeroKarvinen.com!

Well done, you got your “Hello world!”.

Troubleshooting

$ cf-agent --no-lock --file ./hello_tero.cf  # does not work without sudo
2016-11-11T10:04:53+0000    error: cf-promises needs to be installed in /home/vagrant/.cfagent/bin for pre-validation of full configuration
vagrant@cfe:~/shared/cfengine$

Use sudo to use the system wide environment. Without sudo, cfengine expects you to have per-user settings in your home directory.

See also

CFEngine 3.7 Documentation – Examples and Tutorials [WWW Document], n.d. URL https://docs.cfengine.com/lts/examples.html (accessed 11.11.16).

Admistrivia

Updated: Fixed links.

Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Picks

  • Boxing Clock for AndroidOcton8 Diving T-ShirtsShaking Tower Panda Android GameLearn Chinese with Android
  • Student projects