Ask Your Question

Puppet Basic error: str2bool(): Unknown type of boolean given in manifest

asked 2013-12-03 20:17:14 -0600

knock2puppet gravatar image

updated 2013-12-04 01:50:06 -0600

spuder gravatar image

Hello Puppet Gurus, I am repeatedly getting same error for a simple manifest, please help. Below is manifest code:


 if str2bool("$operatingsystem") {
    notice {"just tetsing this stuff":}


And error is as below Error: str2bool(): Unknown type of boolean given at


edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2013-12-04 01:56:22 -0600

spuder gravatar image

updated 2013-12-05 11:40:14 -0600

The facter fact $operatingsystem returns a value such as Cent or Ubuntu.

Try the following syntax

  case $operatingsystem {
    CentOS,RedHat: {     
        notify {"the os is Cent/RHEL":}       
    Debian,Ubuntu: {
        notify {"the os is Ubuntu/Debian:}   
        fail("Operating System not supported") 


The str2bool is only intended to work on "boolean-like" things

str2bool This converts a string to a boolean. This attempt to convert strings that contain things like: y, 1, t, true to 'true' and strings that contain things like: 0, f, n, false, no to 'false'.

Type: rvalue

In your example, Every server ... (more)

edit flag offensive delete link more

answered 2013-12-04 13:37:44 -0600

knock2puppet gravatar image

Thanks for your reply, however I was thinking that should work because as per puppet language "Empty strings are false; all other strings are true. " So if $operatingsystem returns a non-empty string then it should execute the code inside if block.

edit flag offensive delete link more


I've updated my answer

spuder gravatar imagespuder ( 2013-12-04 18:34:14 -0600 )edit

answered 2013-12-05 16:32:19 -0600

gabe_sky gravatar image

The fact $::operatingsystem is pretty much guaranteed to be set, no matter what. Sticking to your example, try:

  if $::operatingsystem { notify { 'hello': } }

To see it be false, use a non-existent fact

  if $::fluxcapacitor { notify { 'hello': } }
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-12-03 20:17:14 -0600

Seen: 901 times

Last updated: Dec 05 '13