Skip to content

Commit

Permalink
Add more logging when keys are selected or corrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeiser authored and tyler-ball committed Apr 6, 2015
1 parent 7254f7c commit 78f2a41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/chef/provider/private_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def load_current_resource
end
rescue
# If there's an error reading, we assume format and type are wrong and don't futz with them
Chef::Log.warn("Error reading #{new_path}: #{$!}")
end
else
resource.action :delete
Expand Down
18 changes: 10 additions & 8 deletions lib/cheffish.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
require 'chef/run_list/run_list_item'
require 'cheffish/basic_chef_client'
require 'cheffish/server_api'
require 'chef/knife'
require 'chef/config_fetcher'
require 'chef/log'
require 'chef/application'

module Cheffish
NAME_REGEX = /^[.\-[:alnum:]_]+$/

Expand Down Expand Up @@ -92,8 +84,10 @@ def self.get_private_key(name, config = profiled_config)
def self.get_private_key_with_path(name, config = profiled_config)
if config[:private_keys] && config[:private_keys][name]
if config[:private_keys][name].is_a?(String)
Chef::Log.info("Got key #{name} from Chef::Config.private_keys.#{name}, which points at #{config[:private_keys[name]]}. Reading key from there ...")
return [ IO.read(config[:private_keys][name]), config[:private_keys][name] ]
else
Chef::Log.info("Got key #{name} raw from Chef::Config.private_keys.#{name}.")
return [ config[:private_keys][name].to_pem, nil ]
end
elsif config[:private_key_paths]
Expand All @@ -104,6 +98,7 @@ def self.get_private_key_with_path(name, config = profiled_config)
if ext == '' || ext == '.pem'
key_name = key[0..-(ext.length+1)]
if key_name == name
Chef::Log.info("Reading key #{name} from file #{private_key_path}/#{key}")
return [ IO.read("#{private_key_path}/#{key}"), "#{private_key_path}/#{key}" ]
end
end
Expand Down Expand Up @@ -223,4 +218,11 @@ def remove_role(*roles)

# Include all recipe objects so require 'cheffish' brings in the whole recipe DSL

require 'chef/run_list/run_list_item'
require 'cheffish/basic_chef_client'
require 'cheffish/server_api'
require 'chef/knife'
require 'chef/config_fetcher'
require 'chef/log'
require 'chef/application'
require 'cheffish/recipe_dsl'
2 changes: 1 addition & 1 deletion lib/cheffish/rspec/chef_run_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def output_for_failure_message
message << "--- ---\n"
message << "--- Chef Client Logs ---\n"
message << "--- ---\n"
message << logs.string
message << logs
end
message
end
Expand Down

0 comments on commit 78f2a41

Please sign in to comment.