The exists? method retrieves the ensure state of the resource. A Boolean is returned, as shown in the following code:
Puppet::Type.type(:mynewtype).provide(:yum) do
...
confine :osfamily => :redhat
defaultfor: osfamily => :redhat
...
def exists?
begin
rpm('-q', resource[:name])
rescue Puppet::ExecutionFailure => e
false
end
end
...
end