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

(MODULES-10827) Exported sshkey already exists error #38

Merged

Conversation

Dorin-Pleava
Copy link
Contributor

Using module https://github.com/ghoneycutt/puppet-module-ssh to export
and collect sshkey resources from nodes, an 'already declared' error
appears.

This happened because when the catalog is first converted to resouces,
the sshkey resource is added via
https://github.com/puppetlabs/puppet/blob/main/lib/puppet/resource/catalog.rb#L137,
where 'resource.ref'(https://github.com/puppetlabs/puppet/blob/main/lib/puppet/type.rb#L2548)
uses 'self.title'.
Since self.title goes to the title method defined in type.rb, it will
return a different title than the title method from
https://github.com/puppetlabs/puppetlabs-sshkeys_core/blob/main/lib/puppet/provider/sshkey/parsed.rb#L31.
This mismatch try to add both resource, resulting in the 'already
declared' error.

@Dorin-Pleava Dorin-Pleava requested a review from a team October 5, 2020 12:10
@puppet-community-rangefinder
Copy link

sshkey is a type

Breaking changes to this file MAY impact these 34 modules (near match):

This module is declared in 5 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@Dorin-Pleava
Copy link
Contributor Author

I could not reproduce the error when applying a manifest similar to the export and collecting in the https://github.com/ghoneycutt/puppet-module-ssh module.

#test.pp
  @@sshkey { $::fqdn :
    ensure       => present,
    host_aliases => [$::hostname, $::ipaddress, $::ipaddress6],
    type         => 'rsa',
    key          => '...key...',
  }
 Sshkey <<||>> {
  target => '/etc/ssh/ssh_known_hosts',
}

Using module https://github.com/ghoneycutt/puppet-module-ssh to export
and collect sshkey resources from nodes, an 'already declared' error
appears.

This happened because when the catalog is first converted to resouces,
the sshkey resource is added via
https://github.com/puppetlabs/puppet/blob/main/lib/puppet/resource/catalog.rb#L137,
where 'resource.ref'(https://github.com/puppetlabs/puppet/blob/main/lib/puppet/type.rb#L2548)
uses 'self.title'.
Since self.title goes to the title method defined in type.rb, it will
return a different title than the title method from
https://github.com/puppetlabs/puppetlabs-sshkeys_core/blob/main/lib/puppet/provider/sshkey/parsed.rb#L31.
This mismatch try to add both resource, resulting in the 'already
declared' error.
@mihaibuzgau mihaibuzgau merged commit f64d389 into puppetlabs:main Oct 6, 2020
@GabrielNagy GabrielNagy added the bug Something isn't working label Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants