项目需要获取本机ip,在文档中没有找到相应的内建变量,而cfengine2是有的,于是上邮件列表问。
答案是有这么个变量的:sys.ipv4 sys.ipv4[eth0]
sys.ipv4 is mentioned a couple of times en passent in the cf3
reference, see for examplehttp://www.cfengine.org/manuals/cf3-reference.html#Function-splayclass.
I tried a simple report:
bundle agent dev{
reports:
solaris::
“my ip is ${sys.ipv4}”
}which gave the expected result.
sys.ipv4 should probably have been listed in the section on sys
variables (at http://www.cfengine.org/manuals/cf3-reference.html#Variable-context-sys),
but isn’t there because “There are too many possibilities to document
in the manual”, hehe. However, you should be able to figure it out
with the examples given in the docs and in this thread.
然后另一位boss说:
I’ll look into a workaround for this. Clearly it needs to be fixed.
The documentation is built automatically from the code, so all the different
interfaces make it tricky in this case.
怪不得我觉得cfengine3的手册如此之烂……