Method: Puppet::Property::Ensure#retrieve
- Defined in:
- lib/puppet/property/ensure.rb
#retrieve ⇒ Symbol
Retrieves the is value for the ensure property. The existence of the resource is checked by first consulting the provider (if it responds to ‘:exists`), and secondly the resource. A a value of `:present` or `:absent` is returned depending on if the managed entity exists or not.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/puppet/property/ensure.rb', line 74 def retrieve # XXX This is a problem -- whether the object exists or not often # depends on the results of other properties, yet we're the first property # to get checked, which means that those other properties do not have # @is values set. This seems to be the source of quite a few bugs, # although they're mostly logging bugs, not functional ones. prov = @resource.provider if prov && prov.respond_to?(:exists?) result = prov.exists? elsif @resource.respond_to?(:exists?) result = @resource.exists? else raise Puppet::DevError, _("No ability to determine if %{name} exists") % { name: @resource.class.name } end if result return :present else return :absent end end |