Book Image

Puppet Cookbook

Book Image

Puppet Cookbook

Overview of this book

Table of Contents (17 chapters)
Puppet Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Importing dynamic information


Even though some system administrators like to wall themselves off from the rest of the office using piles of old printers, we all need to exchange information with other departments from time to time. For example, you may want to insert data into your Puppet manifests that is derived from some outside source. The generate function is ideal for this. Functions are executed on the machine compiling the catalog (the master for centralized deployments); an example like that shown here will only work in a masterless configuration.

Getting ready

Follow these steps to prepare to run the example:

  1. Create the script /usr/local/bin/message.rb with the following contents:

    #!/usr/bin/env ruby
    puts "This runs on the master if you are centralized"
    
  2. Make the script executable:

    $ sudo chmod a+x /usr/local/bin/message.rb
    

How to do it…

This example calls the external script we created previously and gets its output:

  1. Create a message.pp manifest containing the following:

    $message =...