Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm looking at using CFEngine on some linux servers.
My problem is that I need to be able to apply separate policys depending on the server. I looked all over their documentation, and I cannot find anywhere that says that that can or cannot be done.
Is that possible using CFEngine? Or should I look somewhere else.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

It's been a long time ago without using CFengine, but we faced a similar problem when we were using it. Finally, we came up with a solution, using a dynamic bundlesequence. I'm rescuing and modifying an old snippet of code, so the syntax may be wrong, but I think that you'll get an idea.

bundle common g { 
    classes: 
        "some_servers" expression => "someserver01|someserver02";
        "another_servers" expression => "anotherserver01|anotherserver02";
        # Define other classes for your hosts here as needed
    vars:
        any::
            "bs_common" slist => {
                "bundle_1"
            };

        some_servers::
            "bs" slist => {
                "@(g.bs_common)",
                "bundle_2",
                "bundle_3",
            };

        another_servers::
            "bs" slist => {
                "@(g.bs_common)",
                "bundle_3",
            };
}

body control common {
    bundlesequence => {
        "@(g.bs)",
    };
}
share|improve this answer

You can use classes to define where the policies will be applied, and by default Cfengine creates a class with the hostname of every server it's running.

For example, in the following promisse if the server hostname is server01 Cfengine will report "Hello master" (check syslog to read the reports), if the hostname is server02 Cfengine will report "Hello slave":

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

bundle agent hello
{
  reports:

    server01::

      "Hello master!"
        comment => "It's just a dummy report for server01";

    server02::

      "Hello slave!"
        comment => "It's just a dummy report for server02";
}

Ps. You can run this example policy from a file named hello.cf with:

cf-agent -I -f hello.cf

You can find more information about classes and operations using them in the official docs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.