[Puppet Users] modifying file(s) on the fly

Sans
2012-05-21T21:33:46Z

Dear all,

I''m trying to figure out how to do this - first copy a
"common" file to
every node and then modify the file according to the node type. I''ve
tried
this:


if $node_type == ''wn'' {
>         $port = ''8649''
>         $desc = ''Worker Nodes''
> }
>
> exec {
>     ''n_desc'':
>     command     => "sed -ic ''/cluster {/,/}/s/name =
\"[^\"]*\"/name =
> \"\''\"$desc\"\''\"/''
''$fname''",
>     subscribe   => File["$fname"],
>     refreshonly => false;
>
>     ''n_port'':
>     command     => "sed -ic ''/port\ =\
/{s:[0-9]*$:$port:g}'' ''$fname''",
>     subscribe   => File["$fname"],
>     refreshonly => false;
> }
>
> file {
>     ''gmond.conf'':
>      name    => "$fname",
>      source  =>
''puppet:///modules/ganglia/gmond.conf'',
>      require =>
Exec[''n_desc'',''n_port''],
>      notify  => Service[''gmond''];
> }
>


The problem is the *Exec[''n_desc'',''n_port'']
*is being executed but then it
changing back to the original one as supplied by:  *source  =>
''puppet:///modules/ganglia/gmond.conf''*, which is definitely
not what I
want. How can I make sure it copy the file first and then make the changes?
Or, simply how do I do that? Cheers!!