On 12/10/11 19:12, Guy Matz wrote: > hi! > I've seen it reported that there is no official doc for parsedfile; does > anyone know if this is still true? > > I'm trying to make a new type and getting stuck on how parsedfile works > . . . Any help would be appreciated: > > regarding the "Puppet::Type.type(:newType).provide" line: > 1. What does the ":parsed" label do? Are there other options?
It's the provider name. I don't think it really matters, except that there can't be two provider of the same name for a given puppet type. > 2. Are there other types of ":filetypes" besides ":flat"? Does labeling > as :flat have any affect on the parsing? It looks like there's a handful of variations of crontab formats. Use :flat. > regarding "record_line": > 1. can the "name" parameter be anything? is ":parsed" anything > special? Is the name used for anything? I believe it can be anything. I think the name is used if you ever want to look up for a given record_line. > 2. what exactly do the parenthetic groupings do, e.g. /^\s+(.*)=(.*):$/ ? It's a regex capture. > 3. Is there a relationship between the parenthetic groupings and the > ":fields" label? Yes. I think the first capture will end up in the first 'field' and so on for the subsequent capture/field. > 4. what is the relationship between :fields in provider, "newparams" in > type & fields in manifest/init.pp? The role of a given provider is to fill in resource properties and later on, commit updated properties to the target "physical" resource. So, yes you need a field per newproperty in the type. > 4a. Why do i get the following error when I don't have stuff_1 as > ":optional": Could not evaluate: Field 'stuff_1' is required We need to see the code to help with specific errors. > 5. What does :post_parse do? It allows to run some specific code after the parsing of a given record line happens. It allows to modify was what read, or munge some values... > 6 What does :pre_gen do? It allows to run provider specific code before the to_line operation happens. > 7 Are there any other "mystery" parameter? There's at least process, if you want to use your own parsing instead of relying on the regex. And there is a bunch of options to modify how the parsing happens. Check for more information: Puppet::Util::FileParsing and Puppet::Provider::ParsedFile Hope that will help you :) -- Brice Figureau My Blog: http://www.masterzen.fr/ -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.