From 2c131bfaba0e38cb13c8fcb4cb35acb897315b66 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Fri, 8 Nov 2013 16:13:19 -0300 Subject: [PATCH 1/2] Explicitly set root path for default `*_path` options Chef 11.8.0 (with mixlib-config 2.0) sets `*_path` options by default based on `cookbook_path`. If it is an array (as always in knife-solo), the other paths are also arrays. And #300 will catch that and error out. While the conversion to Array is a regression in Chef itself, we anyway want to set the default path relative to our kitchen root, as `cookbook_path` components might be pointing to somewhere else. --- lib/knife-solo/node_config_command.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/knife-solo/node_config_command.rb b/lib/knife-solo/node_config_command.rb index de76e127..c09ba6d3 100644 --- a/lib/knife-solo/node_config_command.rb +++ b/lib/knife-solo/node_config_command.rb @@ -36,6 +36,8 @@ def self.included(other) :long => '--environment ENVIRONMENT', :description => 'The Chef environment for your node' + # Set default chef_repo_path for Chef >= 11.8.0 + Chef::Config.chef_repo_path = '.' end end From 9b7680314e9394c866ec48c43ad0c7edafe43318 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Fri, 8 Nov 2013 16:24:35 -0300 Subject: [PATCH 2/2] Verify that `node_path` is a String `node_path` made it back to Chef's default configuration in 11.8.0. And as pre 0.3.0 setups won't normally have it explicitly configured, it defaults to being an Array. Also a user might set it to be an Array, which leads knife-solo crashing with the infamous `ERROR: TypeError: no implicit conversion of Array into String`. This escaped from us in GH-300. --- lib/knife-solo/node_config_command.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/knife-solo/node_config_command.rb b/lib/knife-solo/node_config_command.rb index c09ba6d3..3e00163f 100644 --- a/lib/knife-solo/node_config_command.rb +++ b/lib/knife-solo/node_config_command.rb @@ -43,6 +43,10 @@ def self.included(other) def nodes_path path = Chef::Config[:node_path] + if path && !path.is_a?(String) + ui.error %Q{node_path is not a String: #{path.inspect}, defaulting to "nodes"} + path = nil + end path && File.exist?(path) ? path : 'nodes' end