Philip Brown
2012-Nov-19 23:45 UTC
[Puppet Users] inconsistencies with arrays: want multiple requires
I''ve poked around the puppet docs, and google, and so far I''m stuck on an apparent inconsistency of usage, when it comes to using arrays, and variables, interchangably. I should mention this is with puppet 3.0.1 If you use literal arrays, both of the following are possible and accepted by puppet: package{ [''pkg1'', ''pkg2'']: blahblah } service{ foo: require => Package[''pkg1'', ''pkg2''], } However. If I define a variable, $pkglist=[''pkg1'',''pkg2''] Then, while I CAN do package{ $pkglist: blahblah } It seems I cannot do service{ foo: require => Package $pkglist , } This makes me sad :( Can someone tell if if there is some language shenanigans I must do, to get puppet to accept the last bit? -- 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/-/aycc1VNnuKoJ. 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.
joe
2012-Nov-20 01:31 UTC
[Puppet Users] Re: inconsistencies with arrays: want multiple requires
I think you misunderstand what puppet is doing there. Variables are not a literal character replacement, they have types. I think what you want is require => Package[$pkglist] The [] in your variable assignment tells puppet it is an array. The [] in the Package example I provided tells puppet you are referring to packages that have already been defined and not trying to change the Package type''s defaults. On Monday, November 19, 2012 4:45:55 PM UTC-7, Philip Brown wrote:> > I''ve poked around the puppet docs, and google, and so far I''m stuck on an > apparent inconsistency of usage, when it comes to using arrays, and > variables, interchangably. > I should mention this is with puppet 3.0.1 > > If you use literal arrays, both of the following are possible and accepted > by puppet: > > package{ [''pkg1'', ''pkg2'']: > blahblah > } > > service{ foo: > require => Package[''pkg1'', ''pkg2''], > } > > > However. If I define a variable, > $pkglist=[''pkg1'',''pkg2''] > > Then, while I CAN do > package{ $pkglist: > blahblah > } > > It seems I cannot do > > service{ foo: > require => Package $pkglist , > } > > This makes me sad :( > Can someone tell if if there is some language shenanigans I must do, to > get puppet to accept the last bit? > > >-- 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/-/h8Kx08grxvcJ. 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.
Philip Brown
2012-Nov-20 01:46 UTC
[Puppet Users] Re: inconsistencies with arrays: want multiple requires
Huh. I could have SWORN I tried that syntax already. First thing,even. But... it works. Thanks for the reply :) On Monday, November 19, 2012 5:31:25 PM UTC-8, joe wrote:> > I think you misunderstand what puppet is doing there. Variables are not a > literal character replacement, they have types. > > I think what you want is > > require => Package[$pkglist] > > The [] in your variable assignment tells puppet it is an array. > > The [] in the Package example I provided tells puppet you are referring to > packages that have already been defined and not trying to change the > Package type''s defaults. > > On Monday, November 19, 2012 4:45:55 PM UTC-7, Philip Brown wrote: >> >> .... >> However. If I define a variable, >> $pkglist=[''pkg1'',''pkg2''] >> >> Then, while I CAN do >> package{ $pkglist: >> blahblah >> } >> >> It seems I cannot do >> >> service{ foo: >> require => Package $pkglist , >> } >> >> This makes me sad :( >> Can someone tell if if there is some language shenanigans I must do, to >> get puppet to accept the last bit? >> >> >>-- 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/-/OMHClG4DVOYJ. 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.