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

Puppet functions


So what do we know about Puppet functions?

  • We can reference functions from the Puppet manifests... check!

  • Function calls use the function_name(argument1, argument2) syntax … check!

  • Puppet has built-in functions, such as template()... check!

  • Puppet can use custom functions, such as query_nodes() and query_facts(), from the puppetdbquery module... check!

Let's talk about the last bullet point more in detail. How are custom functions created and distributed?

Functions are written in the Ruby programming language, which are stored in the lib/puppet/parser/functions directory in a Puppet module with a name that uses the functionname.rb syntax.

All the functions that are stored in Puppet modules that are available in the Puppet Agent's modulepath will be synchronized at the beginning of each Puppet run. Once the functions have been synchronized, they can be referenced from the Puppet manifests.

There is one important thing to remember about how functions are executed. When running Puppet...