Skip to content

Duplicate package resource when manage_install is false and package is declared outside of module #776

Description

@jmcnatt

Scenario

For module users that use resource-style declarations, integration classes become unusable due to the require datadog_agent declaration in each integration class.

Consider the following snippet:

  $package_name = 'datadog-agent'

  # Install the package
  package { $package_name:
    ensure          => present,
    provider        => $package_provider,
    install_options => $install_options,
  }

  # Implement the module
  class { 'datadog_agent':
    dd_user        => $dd_user,
    dd_group       => $dd_group,
    manage_install => false,
    require        => Package[$package_name],
  }

  class { 'datadog_agent::integrations::disk':
    use_mount          => 'no',
    filesystem_exclude => [
      'none',
      'tmpfs',
      'tracefs',
      'squashfs',
    ],
  }

This implementation results in

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Package[datadog-agent] is already declared at (file: /etc/puppetlabs/code/environments/test/modules/datadog_agent/manifests/init.pp, line: 491); cannot redeclare...

Proposal

The require datadog_agent statement in each module is not necessary, especially given many of the resources already contain statements to require datadog_agent::params::package_name.

Additional Background

My org must implement additional logic to install the datadog-agent package outside of this module, mainly due to limitations of the module (See #742 and #747) and would like to utilize the integration classes as well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions