puppet-openldap icon indicating copy to clipboard operation
puppet-openldap copied to clipboard

Package[openldap] is already declared at

Open stormbard opened this issue 4 years ago • 2 comments

If you already have the package openldap already defined else where with ensure_packages(['openldap-devel', 'openldap', 'openssl'], {'ensure' => 'present'}) you get an error.

Failed on TARGET:
  Apply failed to compile for TARGET: Duplicate declaration: Package[openldap] is already declared at (file: /PATH/modules/profile/manifests/ad.pp, line: 3); cannot redeclare (file: /PATH/.modules/openldap/manifests/client/install.pp, line: 8) (file: /PATH/.modules/openldap/manifests/client/install.pp, line: 8, column: 3)
Failed on 1 target: TARGET

We like to define the installed packages explicitly so this is causing us a few issues. Is it possible to make the module do a check to see if this dependency is already defined before adding it again?

stormbard avatar Apr 23 '21 16:04 stormbard

Is it possible to make the module do a check to see if this dependency is already defined before adding it again?

I would consider this an anti-pattern: I would expect the module to manage the package, and if the package is managed outside of the module, raise an error like it currently does.

If you have a use case for which managing the package in the module is not great, I would rather suggest adding a parameter manage_package that defaults to true and when set to false skip completely package management, like it is done in various modules.

smortex avatar Sep 27 '21 18:09 smortex

The use case is that we have explicit package management defined elsewhere. One source of truth for what packages get installed via puppet rather than asking which module installed that or digging through multiple files. It feels weird that I'm getting punished for being detailed and explicit rather than expecting and hoping a module would do it for me.

stormbard avatar Sep 27 '21 19:09 stormbard