Book Image

LEARNING PUPPET

Book Image

LEARNING PUPPET

Overview of this book

Table of Contents (17 chapters)
Learning Puppet
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The defined type


The defined type is a user-defined Puppet resource type that works in a very similar manner as the parameterized class with exception that it can be called multiple times. Continuing with our bicycle example, if we would create a defined type called bicycle, we could use it to order more than one type of bicycle at the time. In other words, you can order a unicycle and a tricycle in one go. But if you're using a class bicycle, I can only order a unicycle for you or tricycle for me.

Calling the defined type

The defined type is referenced with the exactly the same syntax as when referencing Puppet built-in resource types such as the exec, file, or the user resource.

To reference the defined type called bicycle, we'd do it in the following way:

bicycle { 'unicycle':
    wheels => '1';
}

As you can see, the syntax is almost identical to the bicycle class reference. The only difference is that here we don't begin the definition with a class key word because we are not referencing...