So I''m running puppet 0.24.8 and I''m trying to use a definition where sometimes the "name" parameter will be the same but other parameters will be different and puppet is complaining because it expects "name" parameter to be unique. Is that the way it''s supposed to be? And if so, why? The file resource the definition creates will be different every time so there''s no collision Here''s the scenario: I have a list of files I want to create in 2 different locations and I use an array of those file names to set up an implicit loop. The definition then takes the name and a path parameter to create each file. The problem is that if the name has to be unique, I can''t use an implicit loop because I use the same array of file names twice, but with a different path parameter. So now, if this is how puppet is supposed to work, I''m going to have to explicitly call the definition for each and every file I want to create and pass a unique "name" parameter that''s effectively useless. I''m confused why definition "name" parameters have to be unique when the resources they''re creating are unique. I thought the whole point of definitions was reusability. Cheers, Scott --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Scott wrote:> So I''m running puppet 0.24.8 and I''m trying to use a definition where > sometimes the "name" parameter will be the same but other parameters > will be different and puppet is complaining because it expects "name" > parameter to be unique. > > Is that the way it''s supposed to be?Yes.> And if so, why?The namevar is the primary key of the resource type. You might want to reference the instance for dependencies (like "require => Mydefine[''val'']), so it has to be unique.> Here''s the scenario: I have a list of files I want to create in 2 > different locations and I use an array of those file names to set up > an implicit loop. The definition then takes the name and a path > parameter to create each file. The problem is that if the name has to > be unique, I can''t use an implicit loop because I use the same array > of file names twice, but with a different path parameter. So now, if > this is how puppet is supposed to work, I''m going to have to > explicitly call the definition for each and every file I want to > create and pass a unique "name" parameter that''s effectively useless. > > I''m confused why definition "name" parameters have to be unique when > the resources they''re creating are unique. I thought the whole point > of definitions was reusability.For your description I gather this should look like so: | define explode() { | file { | [ "/location1/${name}", "/location2/${name}" ]: | ... | } | } | | explode{ [ "filea", "fileb", "subdir/filec"]: } or so: | file { | regsubst($array, "^.*$", "${path1}/\0"): | ...; | regsubst($array, "^.*$", "${path2}/\0"): | ...; | } Be aware that only very recent versions of regsubst can handle arrays as first parameter. You should be able to replace the single regsubst.rb file on your puppetmaster without troubles. Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ 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 continue to wish for multidimensional objects. This is another example. seph David Schmitt <david@dasz.at> writes:> Scott wrote: >> So I''m running puppet 0.24.8 and I''m trying to use a definition where >> sometimes the "name" parameter will be the same but other parameters >> will be different and puppet is complaining because it expects "name" >> parameter to be unique. >> >> Is that the way it''s supposed to be? > > Yes. > >> And if so, why? > > The namevar is the primary key of the resource type. You might want to > reference the instance for dependencies (like "require => > Mydefine[''val'']), so it has to be unique.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---