Skip to content

puppet agent include the APT class locking it and will make other .pp fail if they include apt #731

@aqueos

Description

@aqueos

Describe the Bug

hi,

This module include the class apt but if it is called elsewhere with parameters this will conflict.

If included elsewhere on a node it will lead to :

Error while evaluating a Resource Statement, Duplicate declaration: Class[Apt] is already declared;

Expected Behavior

It should not think important class like the APT one is used only in the module as it can be used elsewhere with parameters and other things. a quick test can help i think ?

+      if !defined(Class['apt']) {
+          include apt
+      }

this seems enough to prevent this :)

Steps to Reproduce

Steps to reproduce the behavior:
use in a node the apt class, then use the puppet agent module.

Environment

  • Version [e.g. 1.27.0]├── puppetlabs-puppet_agent (v4.20.1)
  • Platform [e.g. Ubuntu 18.04] debian 11

Additional Context

here is the patch i used:


diff --git a/modules/puppet_agent/manifests/osfamily/debian.pp b/modules/puppet_agent/manifests/osfamily/debian.pp
index 7cbd9d3e..e434f8fd 100644
--- a/modules/puppet_agent/manifests/osfamily/debian.pp
+++ b/modules/puppet_agent/manifests/osfamily/debian.pp
@@ -13,7 +13,9 @@ class puppet_agent::osfamily::debian {
     contain puppet_agent::prepare::package
   } else {
     if getvar('::puppet_agent::manage_repo') == true {
-      include apt
+      if !defined(Class['apt']) {
+          include apt
+      }
       if ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
         $pe_server_version = pe_build_version()
         if $puppet_agent::source {

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions