Created
May 1, 2012 16:14
-
-
Save dayglojesus/2569267 to your computer and use it in GitHub Desktop.
Puppet Type/Provider: Simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple Provider | |
require 'fileutils' | |
Puppet::Type.type(:simple).provide(:simple) do | |
desc "Provides simple useless file creation" | |
def create | |
notice("Creating: #{resource[:name]}") | |
system('/usr/bin/touch', "#{resource[:path]}/#{resource[:name]}") | |
end | |
def destroy | |
notice("Destroying: #{resource[:name]}") | |
system("/bin/rm", "#{resource[:path]}/#{resource[:name]}") | |
end | |
def exists? | |
notice("Checking for existence of: #{resource[:name]}") | |
File.exists?("#{resource[:path]}/#{resource[:name]}") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple.pp | |
simple { 'some_useless_file': | |
path => '/tmp', | |
ensure => 'present', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple Type | |
Puppet::Type.newtype(:simple) do | |
@doc = "Create useless files for demonstration" | |
ensurable | |
newparam(:name) do | |
desc "Name of the file to create" | |
isnamevar | |
end | |
newparam(:path) do | |
desc "Path at which to create the file" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the tip.