I have been messing with this for a while and have had no luck so
hoping someone here can help.
I created a customer type called autofs and a provider that uses
ParsedFile to parse the auto_direct file according to what I found
here: http://www.kartar.net/2010/02/puppet-parsedfile-types-and-providers/
The type is located at .../devl/common/lib/puppet/type/autofs.rb
The provider is located at .../devl/common/lib/puppet/provider/autofs/
autofs.rb
I get the following when running puppetd:
...
notice: /File[/var/opt/lib/puppet]/ensure: created
notice: /File[/var/opt/lib/puppet/provider]/ensure: created
notice: /File[/var/opt/lib/puppet/provider/autofs]/ensure: created
notice: /File[/var/opt/lib/puppet/provider/autofs/autofs.rb]/ensure:
defined content as ''{md5}8469013512e708aaf85740caecae74b8''
notice: /File[/var/opt/lib/puppet/type]/ensure: created
notice: /File[/var/opt/lib/puppet/type/autofs.rb]/ensure: defined
content as ''{md5}66817f006dd23e31556e88a3aa837fd2''
info: Loading downloaded plugin /var/opt/lib/puppet/type/autofs.rb
info: Loading downloaded plugin /var/opt/lib/puppet/provider/autofs/
autofs.rb
debug: Reloading parsed autofs provider
...
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError:
Invalid resource type autofs at .../devl/base/manifests/autodf.pp:8 on
node testserver.test.com
The manifest that uses the type looks like this;
autofs {
"/mnt/test":
source => "testnas:/vol/vol3/mountme";
}
The type is not finished, but so far is coded as follows:
Puppet::Type.newtype(:autofs) do
@doc = "Manage contents of autofs maps, etc."
ensurable
newproperty(:path) do
desc "Location of the auto fs file to manage."
defaultto {
if
@resource.class.defaultprovider.ancestors.include?
(Puppet::Provider::autofs)
@resource.class.defaultprovider.default_target
else
nil
end
}
validate do |value|
unless value =~ /^\/[a-z0-9]+/
raise ArgumentError, "#{value} is not a valid file path"
end
end
end
newproperty(:mount) do
desc "The mountpoint where autofs should mount the file system"
isnamevar
validate do |value|
if value =~ /^\s*#/
raise ArgumentError, "#{value} is not a valid key."
end
end
end
newproperty(:source) do
desc "The source of the file system to mount."
validate do |value|
unless value =~ /[a-z0-9\.]+:\/[a-z0-9\.]+/
raise ArgumentError, "#{value} is not a valid nfs source."
end
end
end
newproperty(:options) do
desc "The options to use when mounting the file system."
validate do |value|
unless value =~ /^-/
raise ArgumentError, "#{value} is not a valid option."
end
end
end
end
The provider is coded as follows:
require ''puppet/provider/parsedfile''
path = nil
case Facter.value(:operatingsystem)
when "Solaris"; path = "/etc/auto_direct"
else
path = "/etc/auto.direct"
end
raise Puppet::Error, "Path not defined." unless File.exists?(path)
Puppet::Type.type(:autofs).provide(:parsed, :parent =>
Puppet::Provider::ParsedFile, :default_target => path, :filetype
=> :flat) do
desc "The autofs provider that uses the ParsedFile class"
text_line :comment, :match => /^#/;
text_line :blank, :match => /^\s*$/;
record_line :parsed, :fields => %w{name options source},
:optional => %w{options}
# :match => %r{(\S+)\s+(\S+)\s+(\S+)},
end
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Well... If there aren''t any ideas on the cause can anyone tell me if I am using ParsedFile correctly? Or if there is a resource for documentation on this class? I am just beginning to use ruby so trying to figure out what is provided by the class by looking at the source is going to be difficult. Thank you On Aug 18, 2:31 pm, nothings_absolute <soren.mor...@gmail.com> wrote:> I have been messing with this for a while and have had no luck so > hoping someone here can help. > > I created a customer type called autofs and a provider that uses > ParsedFile to parse the auto_direct file according to what I found > here:http://www.kartar.net/2010/02/puppet-parsedfile-types-and-providers/ > > The type is located at .../devl/common/lib/puppet/type/autofs.rb > The provider is located at .../devl/common/lib/puppet/provider/autofs/ > autofs.rb > > I get the following when running puppetd: > ... > notice: /File[/var/opt/lib/puppet]/ensure: created > notice: /File[/var/opt/lib/puppet/provider]/ensure: created > notice: /File[/var/opt/lib/puppet/provider/autofs]/ensure: created > notice: /File[/var/opt/lib/puppet/provider/autofs/autofs.rb]/ensure: > defined content as ''{md5}8469013512e708aaf85740caecae74b8'' > notice: /File[/var/opt/lib/puppet/type]/ensure: created > notice: /File[/var/opt/lib/puppet/type/autofs.rb]/ensure: defined > content as ''{md5}66817f006dd23e31556e88a3aa837fd2'' > info: Loading downloaded plugin /var/opt/lib/puppet/type/autofs.rb > info: Loading downloaded plugin /var/opt/lib/puppet/provider/autofs/ > autofs.rb > debug: Reloading parsed autofs provider > ... > err: Could not retrieve catalog from remote server: Error 400 on > SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: > Invalid resource type autofs at .../devl/base/manifests/autodf.pp:8 on > node testserver.test.com > > The manifest that uses the type looks like this; > autofs { > "/mnt/test": > source => "testnas:/vol/vol3/mountme"; > } > > The type is not finished, but so far is coded as follows: > > Puppet::Type.newtype(:autofs) do > @doc = "Manage contents of autofs maps, etc." > > ensurable > > newproperty(:path) do > desc "Location of the auto fs file to manage." > > defaultto { > if > @resource.class.defaultprovider.ancestors.include? > (Puppet::Provider::autofs) > @resource.class.defaultprovider.default_target > else > nil > end > } > > validate do |value| > unless value =~ /^\/[a-z0-9]+/ > raise ArgumentError, "#{value} is not a valid file path" > end > end > end > > newproperty(:mount) do > desc "The mountpoint where autofs should mount the file system" > > isnamevar > > validate do |value| > if value =~ /^\s*#/ > raise ArgumentError, "#{value} is not a valid key." > end > end > end > > newproperty(:source) do > desc "The source of the file system to mount." > > validate do |value| > unless value =~ /[a-z0-9\.]+:\/[a-z0-9\.]+/ > raise ArgumentError, "#{value} is not a valid nfs source." > end > end > end > > newproperty(:options) do > desc "The options to use when mounting the file system." > > validate do |value| > unless value =~ /^-/ > raise ArgumentError, "#{value} is not a valid option." > end > end > end > end > > The provider is coded as follows: > require ''puppet/provider/parsedfile'' > > path = nil > case Facter.value(:operatingsystem) > when "Solaris"; path = "/etc/auto_direct" > else > path = "/etc/auto.direct" > end > > raise Puppet::Error, "Path not defined." unless File.exists?(path) > > Puppet::Type.type(:autofs).provide(:parsed, :parent => > Puppet::Provider::ParsedFile, :default_target => path, :filetype > => :flat) do > > desc "The autofs provider that uses the ParsedFile class" > > text_line :comment, :match => /^#/; > text_line :blank, :match => /^\s*$/; > > record_line :parsed, :fields => %w{name options source}, > :optional => %w{options} > # :match => %r{(\S+)\s+(\S+)\s+(\S+)}, > end-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mon, Aug 22, 2011 at 7:35 AM, nothings_absolute <soren.morton@gmail.com> wrote:> > Well... If there aren''t any ideas on the cause can anyone tell me > if I am using ParsedFile correctly? Or if there is a resource for > documentation on this class? I am just beginning to use ruby so trying > to figure out what is provided by the class by looking at the source > is going to be difficult.You can look at other types and provider based on ParsedFile. I don''t believe there''s any official documentation.> On Aug 18, 2:31 pm, nothings_absolute <soren.mor...@gmail.com> wrote: >> I have been messing with this for a while and have had no luck so >> hoping someone here can help. >> >> I created a customer type called autofs and a provider that uses >> ParsedFile to parse the auto_direct file according to what I found >> here:http://www.kartar.net/2010/02/puppet-parsedfile-types-and-providers/ >> >> The type is located at .../devl/common/lib/puppet/type/autofs.rb >> The provider is located at .../devl/common/lib/puppet/provider/autofs/ >> autofs.rb >> >> I get the following when running puppetd: >> ... >> notice: /File[/var/opt/lib/puppet]/ensure: created >> notice: /File[/var/opt/lib/puppet/provider]/ensure: created >> notice: /File[/var/opt/lib/puppet/provider/autofs]/ensure: created >> notice: /File[/var/opt/lib/puppet/provider/autofs/autofs.rb]/ensure: >> defined content as ''{md5}8469013512e708aaf85740caecae74b8'' >> notice: /File[/var/opt/lib/puppet/type]/ensure: created >> notice: /File[/var/opt/lib/puppet/type/autofs.rb]/ensure: defined >> content as ''{md5}66817f006dd23e31556e88a3aa837fd2'' >> info: Loading downloaded plugin /var/opt/lib/puppet/type/autofs.rb >> info: Loading downloaded plugin /var/opt/lib/puppet/provider/autofs/ >> autofs.rb >> debug: Reloading parsed autofs provider >> ... >> err: Could not retrieve catalog from remote server: Error 400 on >> SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: >> Invalid resource type autofs at .../devl/base/manifests/autodf.pp:8 on >> node testserver.test.comThe issue here appears to be a problem with puppet master finding your custom type. I don''t know if /devl/ is part of your puppet master module path. Check your config and you can also try: RUBYLIB=.../devl/common/lib/ puppet master --no-daemonize -v Also if you just developing it, puppet apply with the appropriate module path might be easier to troubleshoot than the full agent/master mode. Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.