Brett Cave
2011-Apr-07 12:44 UTC
[Puppet Users] sourceselect & multiple sources not working
Hi, I am trying to configure a file resource with multiple sources, and browsing list archives and forums seems to indicate that sourceselect parameter with an array for the source param. But the final file gets created using the first matching parameter in the array. file { ''/etc/sysconfig/myconfig'': sourceselect => all, source => [ "puppet:///modules/app/$env/sysconfig.$hostname", "puppet:///modules/app/sysconfig-base" ], owner => ''someuser'', group => ''somegroup'', mode => ''0664'', require => Package[''app''], } If i set source to either 1 or the other, instead of an array, it works as expected. by swapping the 2 array elements around, i get either the hostname version only, or the base version only, but the content is never merged (i get the content of the first element). Is this the correct way to have multiple source files merged? puppet / puppet-master version (RHEL rpm): 2.6.6-0.5 brett -- 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.
Felix Frank
2011-Apr-07 13:04 UTC
Re: [Puppet Users] sourceselect & multiple sources not working
Hi, On 04/07/2011 02:44 PM, Brett Cave wrote:> Hi, > > I am trying to configure a file resource with multiple sources, and > browsing list archives and forums seems to indicate that sourceselect > parameter with an array for the source param. But the final file gets > created using the first matching parameter in the array.note here http://docs.puppetlabs.com/references/stable/type.html#file that sourceselect "is only used in recursive copies". Single files cannot be merged. After all, how would you define the merge of two files? If you want to concatenate the files, you may want to abuse the template() function for that. But please don''t ;-) 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.
Brett Cave
2011-Apr-07 13:35 UTC
Re: [Puppet Users] sourceselect & multiple sources not working
On Thu, Apr 7, 2011 at 3:04 PM, Felix Frank <felix.frank@alumni.tu-berlin.de> wrote:> note here http://docs.puppetlabs.com/references/stable/type.html#file > that sourceselect "is only used in recursive copies". >ah ok. thanks Single files cannot be merged. After all, how would you define the merge> of two files? >concat :p - i.e. append file contents to each in the order they are listed> If you want to concatenate the files, you may want to abuse the > template() function for that. But please don''t ;-) >I did come across this too - http://projects.puppetlabs.com/issues/5158, and implemented this: custom function added: module Puppet::Parser::Functions newfunction(:cat, :type => :rvalue) do |args| args.join("") end end files then uses content: content => cat(file("/etc/puppet/modules/app/files/sysconfig-base"), file("/etc/puppet/modules/app/files/$env/sysconfig.$hostname")), Just need to add in some path detection or some variable so that I don''t have to specify the path the files (is there a variable available that gives $module_path? ) brett> 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. > >-- 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.
Bernardo Costa
2012-Nov-12 20:05 UTC
Re: [Puppet Users] sourceselect & multiple sources not working
I also have a similar problem. I want to create/append a file (automount map) whose lines are independent. For me the best way to handle it would be splitting it into chunks and then decide based on the manifest file which chunk a group of hosts should get on the server. Is it possible ? Em quinta-feira, 7 de abril de 2011 10h35min14s UTC-3, Brett Cave escreveu:> > > > On Thu, Apr 7, 2011 at 3:04 PM, Felix Frank <felix...@alumni.tu-berlin.de<javascript:> > > wrote: > >> note here http://docs.puppetlabs.com/references/stable/type.html#file >> that sourceselect "is only used in recursive copies". >> > > ah ok. thanks > > Single files cannot be merged. After all, how would you define the merge >> of two files? >> > > concat :p - i.e. append file contents to each in the order they are listed > > >> If you want to concatenate the files, you may want to abuse the >> template() function for that. But please don''t ;-) >> > > I did come across this too - http://projects.puppetlabs.com/issues/5158, > and implemented this: > custom function added: > > module Puppet::Parser::Functions > newfunction(:cat, :type => :rvalue) do |args| > args.join("") > end > end > > > files then uses content: > content => cat(file("/etc/puppet/modules/app/files/sysconfig-base"), > file("/etc/puppet/modules/app/files/$env/sysconfig.$hostname")), > > Just need to add in some path detection or some variable so that I don''t > have to specify the path the files (is there a variable available that > gives $module_path? ) > > brett > > >> 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...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> puppet-users...@googlegroups.com <javascript:>. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/d2zYQCwvLjwJ. 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.