木偶:如何写出适当的“条件和条件”声明?

我写了一个“今日消息”Puppet模块,影响我公司所有的代理服务器。 在模板文件中,我有以下“if语句”:

<% if @hostname !~ /^haproxy\d+/ and @hostname =~ /proxy\d+/ -%> if [ "$(cat $LBMEMFILE)" = "0" ]; then echo -e "\e[35m Membeship in LB: Yes" elif [ "$(cat $LBMEMFILE)" = "2" ]; then echo -e "\e[35m Membeship in LB: No $LISTMEMFILE" fi <% end -%> 

它的意义:

如果主机名为proxy0-100而不是^ haproxy0-100,则向motd脚本添加一行。

但由于某种原因,这种说法不起作用。

我也尝试使用“除非”,但无济于事。

如果我删除第一行中的“和”之后的语句,它就像一个魅力。

这是我得到的错误:

 Error: Could not retrieve catalog from remote server: Error 400 on SERVER: undefined method `empty?' for nil:NilClass at /etc/puppet/environments/production/manifests/site.pp:1 on node haproxy02.company.com Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run 

我究竟做错了什么?

提前致谢

我发现这个问题…导致错误的.yaml文件中有一个额外的空间。 谢谢你的帮助。