Hello, > What are you trying to accomplish that led you down this path? I am trying to make a simple text line type that will work like: http://projects.puppetlabs.com/projects/puppet/wiki/Simple_Text_Patterns But without using external programs. Also I wanted to add the ability to to search the line by regex.
I thought that using ParsedFile this would be easier, but seems that I will have to write it using simple puppet type and provider. Thank you. -- Maxim Ianoglo On Apr 18, 8:55 pm, Luke Kanies <[email protected]> wrote: > On Apr 16, 2010, at 10:43 AM, Maxim Ianoglo wrote: > > > > > > > Hello, > > > Trying to make a custom type > > > Type: > > module Puppet > > newtype(:simple_line) do > > > ensurable > > > newparam(:name) do > > isnamevar > > end > > > newproperty(:target) do > > defaultto { > > if > > �[email protected]? > > Puppet::Provider::ParsedFile > > �[email protected]_target > > else > > nil > > end > > } > > end > > > newproperty(:pcre_pattern) do > > validate do |value| > > if value.class != String > > raise ArgumentError, "Shoult be string" > > else > > super > > end > > end > > end > > > newproperty(:line) do > > validate do |value| > > if value.is_a? String > > raise ArgumentError, "Shoult be string" > > else > > super > > end > > end > > end > > end > > end > > > Provider: > > require 'puppet/provider/parsedfile' > > > target = "/tmp/simple_line_dummy_file" > > > Puppet::Type.type(:simple_line).provide( > > :parsed, > > :parent => Puppet::Provider::ParsedFile, > > :default_target => target, > > :filetype => :flat > > ) do > > > text_line :comment, > > :match => @resource.value(:pcre_pattern) > > Here's your problem - @resource is being evaluated in the provider > class, where it resolves to nil. > > There isn't really any good way to have ParsedFile dynamically split > files based on a value passed into a resource - the regex in that case > is resource-specific, but the file covers many resources. > > What are you trying to accomplish that led you down this path? > > > text_line :blank, > > :match => /^\s*$/ > > > record_line :parsed, > > :fields => %w{line} > > end > > > But I keep getting this error: NoMethodError: undefined method `value' > > for nil:NilClass > > > How can i fix this ? > > -- > Getting caught is the mother of invention. --Robert Byrne > --------------------------------------------------------------------- > Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
