是否可以“断言”在木偶?
有没有办法断言 puppet 中的变量(或更具体地说,事实)具有特定值,如果没有则中止安装?
作为背景,情况如下:
在大多数情况下我可以引用主机名,但有时我需要使用 IP 地址。例如,我们的日志收集器主机需要在防火墙中为几台特定计算机(而不是整个子网)打开一个端口。我需要使用 IP 地址在防火墙上打开一个漏洞。由于计算机的 IP 地址不会更改,因此我计划将 IP 地址编码为配置的一部分,但我想检查各个主机的实际 IP 地址是否与其配置中的 IP 地址匹配,如果出现以下情况,则会失败事实并非如此。这可能吗?
Is there a way to assert that a variable (or more specifically, a fact) in puppet has a particular value, and to abort the installation if it doesn't?
For background, here is the situation:
In most cases I can refer to hostnames, but sometimes I need to use an IP address. For example, our log collector host needs to open a port in the firewall for several specific machines (and not a whole subnet). I need to use IP addresses to open a hole in the firewall. Since the IP addresses of machines don't change, I was planning on encoding the IP address as part of the configuration, but I'd like to check on the individual hosts that the actual IP address matches the one in its configuration and fail if it doesn't. Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这样的事情会起作用:
fail()
function 导致解析失败。将其包装在条件中应该会获得您想要的assert
行为。我尚未测试此特定用法,但如果解析失败,则不会编译新目录,并且客户端不会得到任何内容。
I believe something like this would work:
The
fail()
function causes a parse failure. Wrapping it in a conditional should get theassert
behavior you want.I haven't tested this specific usage, but if parsing fails a new catalog isn't compiled and the client doesn't get anything.