The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

ShadowPuppet

ShadowPuppet is a Ruby DSL for Puppet, extracted out of work done by the Rails Machine team on Moonshine

ShadowPuppet provides a DSL for creating collections (manifests) of Puppet Resources in Ruby.

A binary is provided to parse and execute a ShadowPuppet::Manifest.

Example Manifests

A Manifest is an executable collection of Puppet Resources (see the Type Reference ):

class ManifestExample < ShadowShadow::Manifest
  recipe :sample
  recipe :lamp, :ruby               # queue calls to self.lamp and self.ruby when executing
  recipe :mysql, {                  # queue a call to self.mysql passing the provided hash as an option
    :root_password => 'OMGSEKRET'
  }

  def sample
    exec :foo, :command => '/bin/echo "foo" > /tmp/foo.txt'
    package :foo, :ensure => :installed
    file '/tmp/example.txt', :ensure => :present, :contents => Facter.to_hash_inspect
  end

  def lamp
    #install a basic LAMP stack
  end

  def ruby
    #install a ruby interpreter and tools
  end

  def mysql(options)
     #install a mysql server and set the root password to options[:root_password]
  end

end

To execute the above manifest, instantiate it and call execute on it:

m = ManifestExample.new
m.execute

As shown in the +sample+ method in ManifestExample above, instance methods are created for each Puppet::Type available on your system. These methods behave identically to the Puppet Resources methods documented in the Type Reference

To view a list of all defined methods on your system, run:

ruby -rubygems -e 'require "shadow_puppet";puts ShadowPuppet::Manifest.puppet_type_methods'

The use of methods (+sample+, +lamp+, +ruby+, and +mysql+ above) as a container for resources facilitates recipe re-use through the use of Ruby Modules. For example:

module ApachePuppet
  # Required options:
  #   domain
  #   path
  def php_vhost(options)
    #...
  end
 end

class MyWebMainfest < ShadowPuppet::Manifest
  include ApachePuppet
  recipe :php_vhost, {
    :domain => 'foo.com',
    :path => '/var/www/apps/foo'
  }
end