Host group on CFEngine

爷,独闯天下 提交于 2019-12-13 18:26:36

问题


I have to write a policy for defining various Host groups, for a particular thing it should check set of parameters according to host group.

For example I have 2 different set of web cluster, On one cluster httpd.conf is kept under /usr/local/apache/httpd.conf and for another set it is kept under /etc/httpd/httpd.conf.

I have a policy to check file changes of these configuration but I want a way in which I can define for a particular host group where exactly it should check.

Any Hint, help would be very appreciable.


回答1:


The general answer is that you define a class for each group, and assign the appropriate path onto a variable according to that. For example:

vars:
  group1::
    "httpd_conf" string => "/usr/local/apache/httpd.conf";
  group2::
    "httpd_conf" string => "/etc/httpd/httpd.conf";

Then you use $(httpd_conf) in the file operations, and it will have the correct value according to the group.

The potentially tricker part is how to define those classes. In this case it depends on your setup and your preferences. For example, you could define the classes by explicitly listing the hosts in each group:

classes:
  "group1" or => { "host1", "host2", "host3" };
  "group2" or => { "host4", "host5", "host6" };

Or by matching against hostname patterns:

classes:
  "group1" expression => classmatch("grp1.*");
  "group2" expression => classmatch("grp2.*");

There are other possibilities. For a full treatment, please check Defining classes for groups of hosts in Chapter 6 of my book "Learning CFEngine 3".



来源:https://stackoverflow.com/questions/24300518/host-group-on-cfengine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!