Re: [Puppet Users] How to efficiently manage multiple packages installing in the same directory

Michael DeHaan
Wed, 10 Mar 2010 15:59:10 -0000

>
> site.pp
>
>    import "classes/install_foo.pp"
>    import "classes/install_bar.pp"
>
>    node ''standard.node.local'' {
>       include install_foo
>       include install_bar
>    }
>
> ---
>
> classes/install_foo.pp:
>
>    class install_foo {
>       file { "/":
>          ensure  => directory,
>          recurse => true,
>          source  => "puppet:///files/foo"
>       }
>    }
>
> ---
>
> classes/install_bar.pp:
>
>    class install_bar {
>       file { "/":
>          ensure  => directory,
>          recurse => true,
>          source  => "puppet:///files/bar"
>       }
>    }
>
> --


Yeah, I would recommend not doing this, and would want to know more
about the use case around why you wanted to do it that way.

If you have multiple sets of applications that you don''t want to
package into something LSB compliant, it would be better to install
each seperate app in /opt or /srv, such as

/opt/foo and /opt/bar

That''s not great by "best practices'' guidelines, but it
works and gets
the job done if you don''t want to package things so that they fully
understand /etc and /var and such.

The error you get is because Puppet will not allow the same resource
to be represented twice, but the larger problem is you''re also kind of
subverting the point of the package manager
if you are overlaying files all over the file system.  You lose the
ability manage dependencies and see how what got where, hence I''d
really recommend asking why the use case is like that.

If you''re not deploying a full app, just perhaps a set of data files
or content, be more specific about where it should go:

 file { "/this/is/where/where/the/files/go":
          ensure  => directory,
          recurse => true,
          source  => "puppet:///files/wherever/bar"
       }

Versus doing paths relative to root.

Further, I don''t really know how many files you are distributing this
way, but if it''s the whole OS, that is going to be rather slow and not
entirely deseriable.   If you strictly
have to do this, you might as well just rsync the content with an Exec
task ... though again, it''s better if you can do something else.

--Michael