| Thanks for the excellent report Reinhard Vicinus. The issue is that prefetch creates instances of Puppet::Type::Touchfile::ProviderDefault and sets the properties on it:
(byebug) var instance instance |
@property_hash = {:name=>"a", :ensure=>:present, :data=>"default"} |
@resource = #<Puppet::Type::Touchfile:0x0000556666eb33c8 @parameters={:name=>#<Puppet::Type::Touchfile::ParameterName:0x0000556666e09e18 @resource=#<Puppet::...
|
And then we create an instance of Puppet::Type::Touchfile using only the name, provider and title https://github.com/puppetlabs/puppet/blob/bd47bdd08c0f6e32649052cde80cefea1f6250d2/lib/puppet/type.rb#L1199, and that triggers validation https://github.com/puppetlabs/puppet/blob/bd47bdd08c0f6e32649052cde80cefea1f6250d2/lib/puppet/type.rb#L2376 Then we metaprogram each attribute on the type, e.g. define Puppet::Type::Touchfile::Data. So in other words, the Puppet::Type::Touchfile instances don't have all of the state that is normally set on them such as when the desired values are specified in a manifest which happens here https://github.com/puppetlabs/puppet/blob/bd47bdd08c0f6e32649052cde80cefea1f6250d2/lib/puppet/type.rb#L671. I think the puppet resource touchfile hides this behavior, because it converts the Puppet::Type::Touchfile instance to Puppet::Resource: https://github.com/puppetlabs/puppet/blob/bd47bdd08c0f6e32649052cde80cefea1f6250d2/lib/puppet/indirector/resource/ral.rb#L17, which retrieves the "current" values from the provider. I agree the behavior is confusing, but we're unlikely to change that anytime soon and am going to close this. Feel free to reopen if you'd like to take a pass at fixing this in a backwards compatible way. |