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

Duplicate declaration: Package[wget] is already declared #21

Open
Boran opened this issue Nov 18, 2016 · 12 comments
Open

Duplicate declaration: Package[wget] is already declared #21

Boran opened this issue Nov 18, 2016 · 12 comments

Comments

@Boran
Copy link

Boran commented Nov 18, 2016

HI,

I have wget already define in a base common class that is applied to all servers, so when doing "class { 'scaleio::sds_server': }" one gets:

scaleio::sds_server: Duplicate declaration: Package[wget] is already declared

Should such a common base package really be defined as a dependency? I understand why one does it, but unfortunately puppet does not allow several packages to have the same dependency.

(testing on Ubuntu 16.04 from master)

@Andrey-mp
Copy link
Contributor

Hi,
The 'wget' package is needed for downloading packages for installation.
And I found that some CentOS systems don't have it by default.

It's strange that only 'wget' package raises an error - it is not only one in the common Package list.

@Boran
Copy link
Author

Boran commented Nov 18, 2016

Yes. I did a grep of common puppet modules I use ..

  • puppetlabs-apt, for example uses wget but does not declare it as a dependency.
  • Sonar uses whet but includes https://github.com/maestrodev/puppet-wget which provides a puppet interfaces to wget and coudl presumably be included in several packages.

I wonder what the best practise is for avoiding dependency redeclaration errors in puppet?
Perhaps the idea here_ http://stackoverflow.com/questions/26205727/duplicate-declaration-of-same-resource-defined-in-separate-classes#26215336 is a solution,
or just
if ! defined(Package['wget']) { package { 'wget': ensure => installed } }

(Addendum: i verified that the "if" line above does actually work)

@Andrey-mp
Copy link
Contributor

@Andrey-mp
Copy link
Contributor

I fix this issue in last commit.
Please recheck.

@Boran
Copy link
Author

Boran commented Nov 21, 2016

I pulled master, but don't see a fix.

@Andrey-mp
Copy link
Contributor

c132792

@Boran
Copy link
Author

Boran commented Nov 21, 2016

Ok, yes I have that in master, but I had been looking for something like "! defined"
Where is ensure_resource defined, because it does not work as expected for me. I still get

Duplicate declaration: Package[wget] is already declared in file /mymodule/manifests/init.pp:110; cannot redeclare at /etc/puppet/environments/production/modules/scaleio/manifests/common_server.pp:12

Ah, it is in puppetlabs-stdlib. It would be useful to explain your fix :-)

So a fix of the fix: if "ensure_resource('package', ['libaio', 'numactl', 'wget'], {'ensure' => 'installed'})" is replaced with "ensure_packages(['libaio', 'numactl', 'wget'], {'ensure' => 'present'})" it works fine (for me).

@Andrey-mp
Copy link
Contributor

Is all ok now? :)

@Boran
Copy link
Author

Boran commented Nov 21, 2016

there are no changes on master

git log -1
commit c132792
...
Date: Fri Nov 18 12:17:29 2016 +0300
use ensure_resource for common resources

@Andrey-mp
Copy link
Contributor

This commit changes behavior in 'wget' definition with ensure_resource.
I meant that it should fix your error with re-definition.

@Boran
Copy link
Author

Boran commented Nov 21, 2016

It does not, see 4 messages higher. I had expected that you commit another fix this morning, e.g. with ensure_packages

@Andrey-mp
Copy link
Contributor

hm, but can you check why ensure_resource doesn't work?

@Andrey-mp Andrey-mp reopened this Nov 21, 2016
sushilrai pushed a commit to sushilrai/puppet-scaleio that referenced this issue Jul 13, 2018
LUD-1096 Fix for missing parameters in manifests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants