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 which is derived from some outside source. The generate
function is ideal for this.
Getting ready
Follow these steps to prepare for running the example.
Create the script
/usr/local/bin/message.rb
with the following contents:#!/usr/bin/env ruby puts "Hi, I'm Ruby! Will you play with me?"
Make the script executable:
ubuntu@cookbook:~/puppet$ 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.
Add the following to your manifest:
$message = generate('/usr/local/bin/message.rb') notify { $message: }
Run Puppet:
ubuntu@cookbook:~/puppet$ papply Notice: Hi, I'm Ruby! Will you play with me?
How it works…
The generate
function...