puppetlabs / puppetlabs-patching_as_code

Automated Patching through desired state code
Apache License 2.0
10 stars 13 forks source link

Duplicate Resource Declaration for Java Package #32

Closed yachub closed 3 years ago

yachub commented 3 years ago

Thanks for providing the module, it's working really well so far except for one small issue that I'm having trouble pinpointing.

Describe the Bug

The patching_as_code module is unable to ensure => latest on the package openjdk-7-jre-headless due to a duplicate resource declaration.

Expected Behavior

The patching_as_code module should ensure => latest and be able to update the java package.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Use the puppetlabs-java module to manage the java installation on a node, such as:
    class { 'java':
    distribution => 'jre',
    }
  2. Ensure the a newer java package is available than what is currently installed.
  3. Classify the node in a patching_as_code::patch_group.
  4. When the node reaches the time frame specified in patching_as_code::patch_schedule, every puppet run results in the following error:
    Failed to apply catalog: Cannot alias Package[openjdk-7-jre-headless]
    to [nil, "openjdk-7-jre-headless", :apt]; resource ["Package", nil, "openjdk-7-jre-headless", :apt]
    already declared (file: /opt/puppetlabs/server/data/puppetserver/filesync/client/versioned-dirs/puppet-
    code/production_18b2b688aed30a89a6f194510d72258fa04fae5b/modules/java/manifests/init.pp, line: 123)

Environment

Additional Context

Oddly it seems like this issue should not be occurring since the java module declares the package resource as present and the patching_as_code module should be changing it to latest.

kreeuwijk commented 3 years ago

@yachub thanks for the bug report, I'll take a look. It seems that the way the package is declared:

package { 'java':
    ensure          => $version,
    install_options => $package_options,
    name            => $use_java_package_name,
}

is causing it to evade the existing package detection somehow.

kreeuwijk commented 3 years ago

@yachub fixed in #33 which is now released as v0.7.3 on the Puppet Forge