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 need to insert data into your Puppet manifests which is derived from some outside source. The generate function is very useful for this.

Getting ready…

Create the script /usr/local/bin/latest-puppet.rb on the Puppetmaster with the following contents:

#!/usr/bin/ruby

require 'open-uri'

page = open("http://www.puppetlabs.com/misc/download-options/").read
print page.match(/stable version is ([\d\.]*)/)[1]

How to do it…

  1. Add the following to your manifest:
    $latestversion = generate("/usr/local/bin/latest-puppet.rb") ...

Get Puppet 2.7 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.