I had a weird problem with Puppet 3.2.3 today.

In an older template I had a check for a facter fact (variable) as true:

<% if @has_phpmyadmin -%>
Include conf.d/<%= @fqdn -%>.conf
Include conf.d/phpMyAdmin.conf
<% end -%>
<% if @has_phpxhprof -%>
Include conf.d/xhprof.conf
<% end -%>

This used to work just fine when the has_ variables were defined in facter. But today it stopped working. Both cases would match as though they were true, despite only the phpmyadmin check actually being defined:

[root@markp ~]# facter has_phpmyadmin
true
[root@markp ~]# facter has_phpxhprof
[root@markp ~]# 

[root@markp templates]# facter -p has_phpxhprof
[root@markp templates]# 

The odd thing was, even a test file showed output that didn't match what was happening in the Erb:

notify { "has_phpmyadmin":
    message => $::has_phpmyadmin
}

notify { "has_phpxhprof":
    message => $::has_phpxhprof
}

In the end, it took using the newest syntax for looking up a global variable for the behaviour to match what I wanted/expected/used to see:

<% if scope['::has_phpmyadmin'].eql? 'true' -%>
Include conf.d/<%= @fqdn -%>.conf
Include conf.d/phpMyAdmin.conf
<% end -%>
<% if scope['::has_phpxhprof'].eql? 'true' -%>
Include conf.d/xhprof.conf
<% end -%>

I'm not sure if this is intended behaviour, or whether I'm missing the finer details of the newer variable scope.


Comments

comments powered by Disqus