O'Reilly logo

Puppet 5 Essentials - Third Edition by Felix Frank, Martin Alfke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the type system

Older Puppet versions supported a small set of data types only: Bool, String, Array, and Hash. The Puppet DSL had almost no functionality to check for consistent variable types. Consider the following scenario.

A parameterized class enables other users of your code base to change the behavior and output of the class:

class ssh (  $server = true,){  if $server {    include ssh::server  }}

This class definition checks whether the server parameter has been set to true. However, in this example, the class was not protected from wrong data usage:

class { 'ssh': 
  server => 'false', 
} 

In this class declaration, the server parameter has been given a string instead of a bool value. Since the false string is not empty, the if $server ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required