Commit a07d1e7c authored by Alex Tayts's avatar Alex Tayts
Browse files

reorganize a logic a bit

parent 93118e05
......@@ -16,6 +16,8 @@ Puppet::Type.type(:wallet).provide(:wallet) do
def exists?
if File.file?(@resource[:path])
exists = true
# do not go further than that if a file
# is destined to deletion
return true if @resource[:ensure] == :absent
......@@ -33,28 +35,28 @@ Puppet::Type.type(:wallet).provide(:wallet) do
# Check if a principal we need is present. If absent,
# we do not need further verification
return (princs.any? { |s| s.include?(@resource[:name]) })
exists = (princs.any? { |s| s.include?(@resource[:name]) })
if @resource[:verify] == :true
begin
# try to get a ticket with the keytab
kstart("-q", "-f", @resource[:path], @resource[:name])
# cleanup the keytab
kdestroy()
rescue
# failed to get a ticket i.e. keytab is stale
exists = false
end
end
rescue
# Keytab is damaged, get it out of the way
# and require a refresh from wallet.
Puppet.notice("#{@resource.instance_variable_get(:@path)}: keytab '#{@resource[:path]}' is damaged. Renaming to '#{@resource[:path]}.bad'")
File.rename(@resource[:path], "#{@resource[:path]}.bad")
return false
exists = false
end
end
if @resource[:verify] == :true
if @resource[:type].to_s == "keytab"
begin
# try to get a ticket with the keytab
kstart("-q", "-f", @resource[:path], @resource[:name])
# cleanup the keytab
kdestroy()
exists = true
rescue
exists = false
end
else
else
if @resource[:verify] == :true
# checksum the wallet object and compare to a
# local file
begin
......@@ -71,9 +73,6 @@ Puppet::Type.type(:wallet).provide(:wallet) do
object_md5 = Digest::MD5.hexdigest(wallet_obj)
exists = (object_md5.to_s == local_md5.to_s)
end
else
# Verification not requested. Existence of a file is enough.
exists = true
end
else
# file doesn't exist
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment