On Wed, Nov 09, 2011 at 01:08:37PM -0500, Guy Matz wrote:
> Hi! I am soooo close to getting my vncserver type to work; I have one last
> hurdle. There are two kinds of record lines in a vncserver config file, so
> I have two record_line definitions in my provider. Only one of them gets
> called, though! The one that has the same name, ":parsed", as what I pass
> to provide . . .
>
> require 'puppet/provider/parsedfile'
>
> vncservers = "/etc/sysconfig/vncservers"
>
> Puppet::Type.type(:vncserver).provide(:parsed,
> :parent =>
> Puppet::Provider::ParsedFile,
> :filetype => :flat,
> :default_target => vncservers
> ) do
>
> desc "The vncserver provider that uses the ParsedFile class"
>
> confine :exists => vncservers
>
> text_line :comment, :match => /^\s*#/;
> text_line :blank, :match => /^\s*$/;
>
> record_line :parsed_opts,
> :fields => %w{name pre_geo_opts geometry post_geo_opts},
> :optional => %w{pre_geo_opts post_geo_opts},
> :match => /^VNCSERVERARGS\[(\d+)\]="(.*)\s*-geometry
> (\d+x\d+)(.*)"$/,
> :to_line => proc { |record|
> # Should end up looking like:
> # VNCSERVERARGS[92]="-geometry 1280x1024"
> 'VNCSERVERARGS[' + record[:name] +
> ']="-geometry ' + record[:geometry] + '"'
> };
> record_line :parsed_portuser,
> :fields => %w{name username},
> :match => /^VNCSERVERS="\$VNCSERVERS\s+(\d+):(\w+)\s*"$/,
> :to_line => proc { |record|
> # Should end up looking like:
> # VNCSERVERS="$VNCSERVERS 2:firstuser"
> 'VNCSERVERS="$VNCSERVERS ' +
> record[:name] + ':' + record[:username] + '"'
> };
> end
>
>
> Thanks a lot!!
>
> Guy
To be clear here can you have something like
VNCSERVERARGS[23]=...
VNCSERVERS="$VNCSERVERS 23:user"
Because after parsing the whole file, puppet will have two records with
record[:name] = 23 but the contents are not merged.
So when prefetching happens and you have a resource type with the name 23,
the resource will get a provider with pre_geo_opts, geometry and
post_geo_opts OR a provider with username set but never both.
-Stefan
pgpo4e5LsrlFH.pgp
Description: PGP signature
