| The problem is the instances method assumes the title is unique across all providers of that type, but the package type supports composite namevars. This patch seems to work, but causes the same package to be reported by both rpm and dnf:
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb |
index 6690a451a7..a55d029c08 100644 |
--- a/lib/puppet/type.rb |
+++ b/lib/puppet/type.rb |
@@ -1187,16 +1187,18 @@ class Type |
# We always want to use the "first" provider instance we find, unless the resource |
# is already managed and has a different provider set |
title = instance.respond_to?(:title) ? instance.title : instance.name |
- other = provider_instances[title] |
+ result = new(:name => instance.name, :provider => instance, :title => title) |
+ key = result.uniqueness_key.compact.join(':') |
+ other = provider_instances[key] |
+ puts "KEY #{key}" |
if other |
Puppet.debug { |
"%s %s found in both %s and %s; skipping the %s version" % [self.name.to_s.capitalize, title, other.class.name, instance.class.name, instance.class.name] |
} |
next |
end |
- provider_instances[title] = instance |
+ provider_instances[key] = instance |
|
- result = new(:name => instance.name, :provider => instance, :title => title) |
properties.each { |name| result.newattr(name) } |
result |
end
|
When requesting all packages, it returns all of them, along with the provider parameter:
# puppet resource package |
.. |
package { 'zip': |
ensure => '3.0-23.el8', |
provider => 'dnf', |
} |
package { 'zip': |
ensure => '3.0-23.el8', |
provider => 'rpm', |
} |
package { 'zip': |
ensure => ['2.0.2'], |
provider => 'gem', |
} |
package { 'zip': |
ensure => ['2.0.2'], |
provider => 'puppet_gem', |
}
|
If you ask for an instance by name without specifying a provider, you'll get one of them. I think it's the one from the default provider:
# puppet resource package zip |
package { 'zip': |
ensure => '3.0-23.el8', |
provider => 'dnf', |
}
|
Or you can ask for an instance by name for a specific provider:
# puppet resource package zip provider=gem |
package { 'zip': |
ensure => ['2.0.2'], |
provider => 'gem', |
}
|
|