0

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

Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
  • i think you are using bash code in your template – c4f4t0r Feb 16 '15 at 10:44
  • This is a bash code wrapped in Ruby code. As mentioned above, if I remove the second statement (the one after the `and`) then the statement works like a charm. – Itai Ganot Feb 16 '15 at 10:51

1 Answers1

1

I found the problem... there was an extra space in the .yaml file which caused the error. Thanks for your help.

Itai Ganot
  • 10,644
  • 29
  • 93
  • 146