Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Just an idea ... create a custom facter in your module, for example:

require 'facter'

# Default for non-Linux nodes
#
Facter.add(:my_script_value) do
    setcode do
        nil
    end
end

# Linux
#
Facter.add(:my_script_value) do
    confine :kernel  => :linux
    setcode do
        Facter::Util::Resolution.exec("s3cmd ls s3://bucketname | grep s3://bucketname/objectname* | sort -r | head -1 | awk '{print $4}'")
    end
end

Then in your Puppet manifest you can use the facter like in this example:

$filename = $::my_script_value

Or, you can also test a return value for nil

if $::my_script_value != nil {
   $filename = $::my_script_value
}