I have a class in a module:

# File: modules/selinux/tools.pp
class selinux::tools {
        $packages = ['policycoreutils-python',]

        package { $packages:
                ensure => installed

Then, my default node:

# File: manifests/nodes/default.pp
node default {
        if $selinux {
                include selinux::tools

I restart puppetmaster and the puppet agent. However, the package gets installed in the node even though the selinux fact is false:

$ facter -p selinux

What am I missing here?


The "true" or "false" in the selinux fact is just a string to Puppet, it doesn't treat the contents of the string as a boolean. The correct thing to do is just to compare it to another string:

if $selinux == "true" {
    include selinux::tools

There is a feature request to change the behavior so that Facter booleans are properly treated as Puppet booleans.

  • Is this mis-documentation then? – Belmin Fernandez Dec 4 '11 at 15:09
  • It works! Thanks. Still, according to their documentation, at least some facts are interpreted as bool values. How would I know which are strings and which are bool? – Belmin Fernandez Dec 4 '11 at 15:13
  • Nope - I think that documentation is wrong. Try it for yourself - even 'false' would come up as a positive. – Ken Barber Dec 5 '11 at 12:30
  • Agreed, though it sort of gives the reasoning in the next section. I've filed #11183 as I think the example deserves a big warning and to properly compare how the variable should be tested. – Dominic Cleal Dec 5 '11 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.