Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make module behaviour consistent despite value of stringify_facts #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hybby
Copy link

@hybby hybby commented Feb 22, 2017

Right now, it's possible that the comparison on the $::has_compiler fact may not return the intended result depending on the value of stringify_facts in puppet.conf.

In Puppet 3, this value defaults to true which means all Facts when looked up are passed through #to_s. This means that if the fact has the value of false, it will be considered true when evaluated.

To illustrate this, consider the following:

drew@server# facter -p selinux
false

drew@server# cat /tmp/selinux.pp
if $::selinux {
  notify {"SELinux is enabled":}
} else {
  notify {"SELinux is disabled":}
}

drew@server# grep stringify_facts /etc/puppet/puppet.conf
stringify_facts = true

drew@server# puppet apply /tmp/selinux.pp
<...snip...>
Notice: SELinux is enabled
<...snip...>

If I remember correctly, even blank strings returned from Facter will evaluate to true when flattened.

Since there's already a dependancy on puppetlabs-stdlib, we can use str2bool() to make this backwards compatible. It's a recommended method from Puppet themselves during the upgrade process (source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant