- Mastering Puppet 5
- Ryan Russell Yates Jason Southgate
- 50字
- 2021-07-16 17:46:18
Using the exists? method
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