I am having troubles finding the proper documentation that explains how to access the elements in an array. I have created a function that queries LDAP and returns an array of packages that I will deploy using puppet. In my init.pp file I have something like: $packages = get_packages("cn=computer_name") I know that the ''get_packages'' function returns an array of values that are package names such as ["firefox", "comicLife"]. So I am assuming that $packages = ["firefox", "comicLife"]. What I want to do is to step through this array and deploy the packages listed in the array. I have the code to deploy the packages but I do not know how to step through the members of the array and pass those values onto my pkg_deploy function. Can someone point me in the right direction? Thanks -kurt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2009/4/8 engle <kurt.engle@gmail.com>> > I am having troubles finding the proper documentation that explains > how to access the elements in an array.try feeding the whole array to the package type... package { ["foo", "bar", "baz"]: ensure => latest } I''ve not seen a ''for'' loop in puppet, but then again I''ve never looked properly... :) Gary -- Gary Law Email: garylaw@garylaw.net Chat googletalk/messenger: gary.law@gmail.com iChat/jabber/AIM: gary.law@mac.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This *might* work: package { $packages: ensure => installed } But you might have to do this: define do_stuff { package { $name: ensure => installed } } do_stuff { $packages: } Trevor On Wed, Apr 8, 2009 at 18:39, engle <kurt.engle@gmail.com> wrote:> > I am having troubles finding the proper documentation that explains > how to access the elements in an array. > > I have created a function that queries LDAP and returns an array of > packages that I will deploy using puppet. In my init.pp file I have > something like: > > $packages = get_packages("cn=computer_name") > > I know that the ''get_packages'' function returns an array of values > that are package names such as ["firefox", "comicLife"]. So I am > assuming that $packages = ["firefox", "comicLife"]. What I want to do > is to step through this array and deploy the packages listed in the > array. I have the code to deploy the packages but I do not know how to > step through the members of the array and pass those values onto my > pkg_deploy function. > > Can someone point me in the right direction? > > Thanks > > -kurt > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
no need for the define package { $packages: ensure => installed } will work Let us know if you have problems with that. On Fri, Apr 10, 2009 at 3:55 PM, Trevor Vaughan <peiriannydd@gmail.com>wrote:> > This *might* work: > > package { $packages: ensure => installed } > > But you might have to do this: > > define do_stuff { > package { $name: ensure => installed } > } > > do_stuff { $packages: } > > Trevor > > On Wed, Apr 8, 2009 at 18:39, engle <kurt.engle@gmail.com> wrote: > > > > I am having troubles finding the proper documentation that explains > > how to access the elements in an array. > > > > I have created a function that queries LDAP and returns an array of > > packages that I will deploy using puppet. In my init.pp file I have > > something like: > > > > $packages = get_packages("cn=computer_name") > > > > I know that the ''get_packages'' function returns an array of values > > that are package names such as ["firefox", "comicLife"]. So I am > > assuming that $packages = ["firefox", "comicLife"]. What I want to do > > is to step through this array and deploy the packages listed in the > > array. I have the code to deploy the packages but I do not know how to > > step through the members of the array and pass those values onto my > > pkg_deploy function. > > > > Can someone point me in the right direction? > > > > Thanks > > > > -kurt > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---