We''d like to make the contents of a folder contain all the files from two different folders on the server. Which folder to merge will be different for different client machines. How can I specify that in a file rule? -- 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.
I''m trying to do this using an array variable and the sourceselect parameter. class parent { $sources = [ ''/path/to/first'' ] file { ''...'': ensure => directory, source => $sources, sourceselect => all } } class child { $sources += [ ''/path/to/second'' ] } But it complains that: Error 400 on SERVER: Puppet::Parser::AST::VarDef failed with error TypeError: can''t convert Array into String Is puppet not capable of using an array variable for an array parameter? Do I need to use a special syntax for this? -- 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.
Ah, it works if the variable is in the outer scope: $sources = [ ''/path/to/first'' ] class parent { file { ''...'': ensure => directory, source => $sources, sourceselect => all } } class child { $sources += [ ''/path/to/second'' ] } -- 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.
Correction: this only works if the place that uses the variable (the ''file'' resource) comes after the place where the variable is modified. In our case that meant the child looks like this: class child { $sources += [ ''/path/to/second'' ] include parent } -- 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.
Hi, On 04/04/2011 12:14 PM, Marcus Downing wrote:> Correction: this only works if the place that uses the variable (the > ''file'' resource) comes after the place where the variable is modified. > In our case that meant the child looks like this: > > class child { > $sources += [ ''/path/to/second'' ] > include parent > }sorry to say this, but this looks hell of wrong to me. Don''t do this based on variables. Don''t even think of doing that. Variable scoping already has enough caveats as it is. You''re obfuscating your end. What you probably want to do is this: class child inherits parent { File[''...''] { source +> [ "/path/to/second" ] } } You override the resource''s parameter using plusignment syntax. That would be sort of acceptable, but are you sure this facilitates a folder merge? Afaik, specifying multiple sources will make puppet choose the first that turns out to be valid and ignore all others. If you''re in 2.6, according to the style guide, you should be using class parameters for thise instead of class inheritance as outlined above. HTH, Felix -- 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.
As I said, the "sourceselect => all" parameter is necessary to make puppet merge the listed sources rather than selecting one of them. I take your point that variables are a fragile way of specifying. I''ll try refactoring it based on class parameters, but the list of sources isn''t the same length for the different nodes so it''ll still have to be an array; and it will need to add that array to a list of default sources shared by all instances (that I''d rather not repeat for every one). -- 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.
Hi, On 04/04/2011 06:13 PM, Marcus Downing wrote:> As I said, the "sourceselect => all" parameter is necessary to make > puppet merge the listed sources rather than selecting one of them.ah, thanks for pointing that out again. I completely missed that (nor knew of its existence).> I take your point that variables are a fragile way of specifying. I''ll > try refactoring it based on class parameters, but the list of sources > isn''t the same length for the different nodes so it''ll still have to be > an array; and it will need to add that array to a list of default > sources shared by all instances (that I''d rather not repeat for every one).I don''t see an issue with passing this parameter as an array. Alternatively (if the set of options is limited, which I would assume seeing that you used something not unlike inheritance before), you could just pass a flag parameter (sources = "all", sources = "some" etc.) and declare your array of sources in a case statement inside the parameterized class. Regards, Felix -- 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, Apr 4, 2011 at 12:13 PM, Marcus Downing <marcus.downing@gmail.com> wrote:> As I said, the "sourceselect => all" parameter is necessary to make puppet > merge the listed sources rather than selecting one of them. > I take your point that variables are a fragile way of specifying. I''ll try > refactoring it based on class parameters, but the list of sources isn''t the > same length for the different nodes so it''ll still have to be an array; and > it will need to add that array to a list of default sources shared by all > instances (that I''d rather not repeat for every one).Have you had any luck with this? I''m trying to do something similar with multiple sources for one directory where each node has a different set of sources. I can explicitly set the list of sources on a per-node basis, but whenever I try to set it using modules, it fails. Thanks, Jeremy -- 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.