CFEngine上的主机组 [英] Host group on CFEngine

查看:91
本文介绍了CFEngine上的主机组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个用于定义各种主机组的策略,对于特定的事情,它应该根据主机组检查参数集.

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.

例如,我有两组不同的Web群集,在一个群集中,httpd.conf保留在/usr/local/apache/httpd.conf下,对于另一个群集,它保留在/etc/httpd/httpd.conf下.

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.

推荐答案

通常的答案是为每个组定义一个类,并根据该类将适当的路径分配给变量.例如:

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";

然后在文件操作中使用$(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.*");

还有其他可能性.要进行完整处理,请检查"学习CFEngine 3的第6章中".

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".

这篇关于CFEngine上的主机组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆