Wrap text
|
|
# cat /tmp/test.pp
ckm { "root": }
##
# cat type/ckm.rb
module Puppet
newtype(:ckm) do
@doc = "Manages entries in /etc/ckm.conf"
ensurable
newparam(:name) do
desc "the main key in ckm.conf"
isnamevar
end
newproperty(:target) do
desc "ckm.conf"
defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
@resource.class.defaultprovider.default_target
else
nil
end
}
end
end
end
##
# cat provider/ckm/parsed.rb
require 'puppet/provider/parsedfile'
ckm = "/tmp/ckm.conf"
Puppet::Type.type(:ckm).provide(:parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => ckm,
:filetype => :flat
) do
desc "Parse and generate ckm.conf."
confine :exists => ckm
text_line :comment, :match => /^#/
text_line :blank, :match => /^\s*$/
record_line :parsed, :fields => %w{name}
end
##
# puppet -v /tmp/test.pp --trace
info: Loading fact apache_version
info: Loading fact netmask
info: Loading fact location
info: Loading fact hardware_platform
info: Loading fact servertype
info: Loading fact topdomain
info: Loading fact domain
info: Stored catalog for puppetmaster in 0.08 seconds
err: Could not create root: Could not find a default provider for ckm
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/providers.rb:39:in `defaultprovider'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/providers.rb:182:in `default'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/attributes.rb:635:in `setdefaults'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/attributes.rb:120:in `eachattr'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/attributes.rb:115:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/attributes.rb:115:in `eachattr'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/attributes.rb:625:in `setdefaults'
/usr/lib/ruby/site_ruby/1.8/puppet/type.rb:247:in `initialize'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/instances.rb:151:in `new'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/instances.rb:151:in `create'
/usr/lib/ruby/site_ruby/1.8/puppet/transportable.rb:87:in `to_type'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:488:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:488:in `to_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:476:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:476:in `to_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:402:in `to_ral'
/usr/bin/puppet:212
Could not find a default provider for ckm
|