I have some software with a list of patches that need to be installed in order. Different hosts want different patches (e.g. development hosts get patches that are not yet ready for production). Obviously I can do this: package { "basepackage": ensure => present, } package { "patch1": ensure => present, require => Package["basepackage"], package { "patch2": ensure => present, require => Package["patch1"], } package { "patch3": ensure => present, require => Package["patch2"], } but I''d like to do something like this: $package_list => ["basepackage", "patch1", "patch2", "patch3"] # The above value would actually come from extlookup() install_packages_in_order { "title": package_list => $package_list } define install_packages_in_order($package_list) { ...insert code here... } or with alternating package names and version numbers: $package_list = ["basepackage", "1.2.3", "patch1", "1.2.3.0.1", "patch2", "1.2.3.0.2", "patch3", "1.2.3.0.3"] I think I can make this work using some ugly code inside inline_template, or maybe writing my own parser functions, but does anybody have any easier suggestions? --apb (Alan Barrett) -- 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.
Hello Alan, I''ve got a file resource that makes sure a specific directory tree is created.. $dirs = ["/var", "/var/lanl", "/var/lanl/puppet"] @file { $dirs : ensure => directory, owner => "root", group => "wheel", mode => 755, links => follow, } I would think that setting up a $packages array in the right order and doing something like: package{ $packages : ensure => present, } would work... I''m currently on 0.25.1, and hoping that it''ll still work that way when I upgrade. Regards, -Roy On 6/15/10 10:00 AM, Alan Barrett wrote:> I have some software with a list of patches that need to be installed in > order. Different hosts want different patches (e.g. development hosts > get patches that are not yet ready for production). > > Obviously I can do this: > > package { "basepackage": > ensure => present, > } > package { "patch1": > ensure => present, > require => Package["basepackage"], > package { "patch2": > ensure => present, > require => Package["patch1"], > } > package { "patch3": > ensure => present, > require => Package["patch2"], > } > > but I''d like to do something like this: > > $package_list => ["basepackage", "patch1", "patch2", "patch3"] > # The above value would actually come from extlookup() > > install_packages_in_order { "title": > package_list => $package_list > } > > define install_packages_in_order($package_list) { > ...insert code here... > } > > or with alternating package names and version numbers: > > $package_list = ["basepackage", "1.2.3", > "patch1", "1.2.3.0.1", > "patch2", "1.2.3.0.2", > "patch3", "1.2.3.0.3"] > > I think I can make this work using some ugly code inside > inline_template, or maybe writing my own parser functions, > but does anybody have any easier suggestions? > > --apb (Alan Barrett) > >-- 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.
Alan Barrett
2010-Jun-16 17:21 UTC
Re: [Puppet Users] Installing several packages in order
On Wed, 16 Jun 2010, Roy Nielsen wrote:> I''ve got a file resource that makes sure a specific directory tree > is created.. > > $dirs = ["/var", "/var/lanl", "/var/lanl/puppet"] > > @file { $dirs : > ensure => directory, > owner => "root", > group => "wheel", > mode => 755, > links => follow, > }Puppet automatically makes each file depend on its parent directory, so your exmple should work.> I would think that setting up a $packages array in the right order > and doing something like: > > package{ $packages : > ensure => present, > }No, that won''t install the packages in any specific order. There are no explicit or implicit dependencies between apckages in your example, but in my case I want each package to explicitly depend on its predecessor in the array. --apb (Alan Barrett) -- 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.
Thomas Bellman
2010-Jun-16 18:21 UTC
Re: [Puppet Users] Installing several packages in order
On 2010-06-16 19:21, Alan Barrett wrote:> No, that won''t install the packages in any specific order. There are no > explicit or implicit dependencies between apckages in your example, but > in my case I want each package to explicitly depend on its predecessor > in the array.How about this: define pkglist_helper() { $pkg = inline_template(''<%= name.split(";")[0] -%>'') $next = inline_template(''<%= name.split(";")[1] or "" -%>'') if $next != "" { package { $pkg: ensure => installed, before => Package[$next]; } } else { package { $pkg: ensure => installed; } } } define packagelist($packages) { $foo = inline_template( ''<% lst = []; 0.upto(packages.length - 1) { |i| lst << packages[i] + ";" + (packages[i+1] or ""); } -%><% lst.join("|") -%>'') $bar = split($foo, "[|]") pkglist_helper { $bar: ; } } Use it like this: packagelist { some-packages--title-does-not-matter: packages => [ "foo", "bar", "gazonk", "del", "xyzzy" ]; } I have only tested it very briefly (using notify instead of package), but it seemed to work. /Bellman -- 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.
Alan Barrett
2010-Jun-16 18:48 UTC
Re: [Puppet Users] Installing several packages in order
On Wed, 16 Jun 2010, Thomas Bellman wrote:> >in my case I want each package to explicitly depend on its predecessor > >in the array. > > How about this:Thank you! I would eventually have written something involving two defines calling eack other, with inline_template to munge the arguments, but I would probably not have found such a simple solution, and I had not yet started writing the code. --apb (Alan Barrett) -- 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.