Skip to content
Snippets Groups Projects
Verified Commit e0e031e3 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Handle the passwordstate server disappearing

parent 6c9ad25e
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,9 @@ module ForemanPasswordstate
root_user = operatingsystem&.root_user || 'root'
host_pass(root_user, password_hash: operatingsystem&.password_hash)
rescue StandardError => e
logger.error "Failed to get root_pass for #{self} - #{e.class}: #{e}"
return Digest::SHA256.digest("#{id}-PlaceholderDueToPasswordstateError")
end
def remove_passwordstate_passwords!
......
......@@ -5,6 +5,10 @@ module ForemanPasswordstate
def host_info
return {} unless host.passwordstate_facet
# Test if host password is readable
root_user = host.operatingsystem&.root_user || 'root'
host.host_pass(root_user, password_hash: host.operatingsystem&.password_hash)
params = { 'parameters' => {
'passwordstate' => {
'server' => host.passwordstate_server.name,
......@@ -17,6 +21,9 @@ module ForemanPasswordstate
params['parameters']['admin_pw'] = host.root_pass if host.operatingsystem.family == 'Windows'
params
rescue StandardError => e
::Logging.logger[::Foreman].error "Failed to render host_info for #{host} - #{e.class}: #{e}"
{}
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment