cfengine

CFEngine match hostname in bundle agent


I am new to CFEngine and i am trying to perform some actions based on hostnames.

eg: all hostnames having stable should contain packages from slist 1 all hostnames having test should contain packages from slist 2

bundle agent package_lists {
packages:
 stable&dist_class::
    "$(user_packages.package_stable)"
            package_policy => "add",
            package_method => yuck,
            classes => if_repaired("package_changed");
}

I want to change this to include hosts with test in them a well

should addition of test be sufficient? I am not able to understand what dist_class:: and stable are.

-stable&dist_class::

+test&stable&dist_class::


Solution

  • I believe you should be using the OR operator '||' rather than an and '&'/'&&' operator (assuming you are talking about classes representing groups of servers for which all three classes require the same package installation). Using the ampersand (&) or dot (.) will only match servers belonging to all three classes rather than individuals. https://docs.cfengine.com/docs/3.5/manuals-language-concepts-classes.html

    If you want to match only servers which match all three class definitions at once then ampersands are (one of) the way to go.

    Personally I like to keep things as atomic as possible so I'd actually define the promises for all three classes separately or create a new class for common packages ensuring that the above servers belong to that class.