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

Mathew Binkley
Tue, 09 Mar 2010 19:41:24 -0000

Hi everyone.  I am trying to manage several different packages using
Puppet.  For the sake of maintainability, each package is installed in
its own separate puppet directory.  Each package would have a separate
install_package.pp script and corresponding folder in /etc/puppet/
files on the server:

    /etc/puppet/files/foo/
                         etc/
                         root/
                         usr/local

   /etc/puppet/files/bar/
                         etc/
                         var/lib

To avoid micromanaging, I would like to simply copy over the contents
of each folder to / on the client.  While each package has directories
in common (/etc for example), all of the files in each package are
orthogonal and not shared between packages.  For example, package foo
will be the only package that will ever install /etc/foo.conf.
Package bar will never manage it.

I have tried to do this using the Puppet config below, but it errors
out with the message below.   Can any one tell me a simple solution
that does not involve micromanaging each unique file or subfolder?
Given the dynamic nature of the packages (new files are added/removed
constantly), this would add a good deal of unnecessary work.

"err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed
with error ArgumentError: Duplicate definition: File[/] is already
defined in file install_foo.pp at line 8; cannot redefine at
install_ibp.pp:8 on node mybox.local"

---

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"
       }
    }