I wrote a "Message of the day" Puppet module which affects all proxy servers in my company. Within the template file, I have the following "if statement":
<% 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 -%>
It's meaning:
If hostname is proxy0-100 and not ^haproxy0-100 then add a line to the motd script.
But for some reason this statement doesn't work.
I also tried using "unless" but to no avail.
If I remove the statement after the "and" in the first line, it works like a charm.
This is the error I'm getting:
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
What am I doing wrong?
Thanks in advance