Create your first Technique

Now we are going to see how to create a simple technique to configure a ntp server, step by step.

1. General information

Let’s start from the beginning. Click on the "New Technique" button and start filling in the General information fields (only name is required).

In our case:

  • Name: Configure NTP
  • Description: Install, configure and ensure the ntpd is running. Uses a template file to configuration.

2. Add and configure generic methods

Now, we have to find and add the generic methods which correspond to the actions we want to execute. In our case, we want to add the following methods:

  • Package install (You can find it in the Package category)

    • This method only take one parameter, the name of the package to install. So here, fill in the package_name field with the value ntp.
  • File from template (You can find it in the File category)

    • This method take two parameters. The first one corresponds to the absolute path of the source file containing a template to be expanded. We are going to use a Rudder variable here to get the correct path. Fill in the source_template field with the value ${path_technique}/templates/ntp.conf.
    • The second corresponds to the absolute path of the destination file. Fill in with the value /etc/ntp.conf.
  • Service restart (You can find it in the Service category)

    • This method only take one parameter, the name of the service we want to restart. So here, fill in the service_name field with the value ntp.
    • Also, we want to restart the service only if it has just been installed, so only if the result classes defined following the execution of Package install method is Repaired (package_install_ntp_repaired). So here, fill in the Other CFEngine classes field in the Conditions panel with the value package_install_ntp_repaired.
  • Service ensure running (You can find it in the Service category)

    • This method only take one parameter, the name of the service we want to check. Again, here, fill in the service_name field with the value ntp.

3. Save and apply your technique

And… It’s already done. Rather fast, right? Don’t forget to save. Now you can see it in the Directives tree, and use it to create a Directive that will be applied on your Nodes thanks to a Rule.