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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to