Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while evaluating a Resource Statement, Duplicate declaration: Package[unattended-upgrades] is already declared #235

Open
JmbFountain opened this issue Oct 6, 2023 · 1 comment
Labels
needs-feedback Further information is requested

Comments

@JmbFountain
Copy link

JmbFountain commented Oct 6, 2023

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.23.0
  • Ruby: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]
  • Distribution: Debian GNU/Linux 12 (bookworm)
  • Module version: 8.0.0

How to reproduce (e.g Puppet code you use)

# Basic config for all Debian nodes
class profile::debianapt {
  # install basic packages
  class { 'apt':
    update => {
      frequency => 'daily',
    },
    purge  => {
      'sources.list' => true
    },
  }
  apt::source { "deb.debian.org-${facts['os']['distro']['codename']}":
    location => 'http://deb.debian.org/debian/',
    repos    => 'main non-free-firmware non-free contrib',
    include  => {src => true}
  }
# noch mehr apt sources

  class { 'unattended_upgrades':
    auto                   => {
      clean  => 'always',
      remove => true
      },
    enable                 => true,
    origins                => [
    'origin=${distro_id},suite=${distro_codename}',
    'origin=${distro_id},suite=${distro_codename}-security',
    'origin=${distro_id},suite=${distro_codename}-backports',
    'origin=${distro_id},suite=${distro_codename}-updates',
    ],
    remove_new_unused_deps => true,
  }
}

What are you seeing

error about duplicate declaration when trying to run puppet agent --test

What behaviour did you expect instead

successfully configuring unattended upgrades

Output log

root:/etc/puppet/code/environments/production# puppet agent --test
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Package[unattended-upgrades] is already declared at (file: /etc/puppet/code/environments/production/modules/profile/manifests/debianapt.pp, line: 16); cannot redeclare (file: /etc/puppet/code/environments/production/modules/unattended_upgrades/manifests/init.pp, line: 50) (file: /etc/puppet/code/environments/production/modules/unattended_upgrades/manifests/init.pp, line: 50, column: 3) on node puppet.jmbfountain.de
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Any additional information you'd like to impart

I'm fairly new to both Puppet and Ruby, so this might just be an error I made and don't know how to correctly google.

I installed the module using puppet module install puppet-unattended_upgrades --version 8.0.0 and declared it using

class { 'unattended_upgrades':
  age => { 'max' => 10 },
}

as shown in the README.

However, if I then try to roll this out to an agent, it says it can't declare unattended_upgrades in the init.pp of the unattended_Upgrades module because it's already declared.

@kenyon
Copy link
Member

kenyon commented Oct 6, 2023

What is the full error message? It should give you filenames and line numbers. Seems like this is coming from your code, because the package resource is only declared once in this module.

@kenyon kenyon added the needs-feedback Further information is requested label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-feedback Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants