Skip to content

Instantly share code, notes, and snippets.

@bodepd
Created September 4, 2014 10:58
Show Gist options
  • Save bodepd/59bdf2f0dc19842a1d58 to your computer and use it in GitHub Desktop.
Save bodepd/59bdf2f0dc19842a1d58 to your computer and use it in GitHub Desktop.
type/provider feature examples
# <module_path>/<module_name>/lib/puppet/type/foo.rb
Puppet::Type.newtype(:foo) do
# on the provider, exists? create, destroy
#
# foo { 'foop':
# ensure => (present|absent)
# }
feature :foo_feature, 'docs'
ensurable
newparam(:name, :namevar => true) do
end
# maps to getter: def thing_to_manage, thing_to_manage=(thing)
newproperty(:thing_to_manage, :required_features => :foo_feature ) do
end
end
# <module_path>/<module_name>lib/puppet/provider/foo/default.rb
Puppet::Type.type(:foo).provide(:default) do
has_feature :foo_feature if false
def exists?
puts 'checking existance'
true
end
def create
puts 'creating'
end
def destroy
puts 'destroying'
end
def thing_to_manage
puts 'getting state of thing'
'value'
end
def thing_to_manage=(value)
puts "setting value to #{value}"
end
end
## example.pp
foo { 'myfoo':
ensure => present,
thing_to_manage => 'some_value',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment