summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Heinen <theinen@tecracer.de>2021-10-08 16:32:27 +0200
committerThomas Heinen <theinen@tecracer.de>2021-10-08 16:32:27 +0200
commit013efca161665aa25bcdbd2a1ba813de3bf1b5d4 (patch)
treec7ddef1e8677def41fe98183360687614a56fc80
parent6ed1102f9602dc94478b30f72824977ebf8257d5 (diff)
downloadchef-013efca161665aa25bcdbd2a1ba813de3bf1b5d4.tar.gz
Allow specifying transport protocol in RFC099 credential files
Signed-off-by: Thomas Heinen <theinen@tecracer.de>
-rw-r--r--chef-config/lib/chef-config/mixin/train_transport.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/chef-config/lib/chef-config/mixin/train_transport.rb b/chef-config/lib/chef-config/mixin/train_transport.rb
index 942f0ab3b7..99d773dace 100644
--- a/chef-config/lib/chef-config/mixin/train_transport.rb
+++ b/chef-config/lib/chef-config/mixin/train_transport.rb
@@ -108,12 +108,14 @@ module ChefConfig
# Load the target_mode config context from config, and place any valid settings into the train configuration
tm_config = config.target_mode
- protocol = tm_config.protocol
- train_config = tm_config.to_hash.select { |k| Train.options(protocol).key?(k) }
- logger.trace("Using target mode options from #{ChefUtils::Dist::Infra::PRODUCT} config file: #{train_config.keys.join(", ")}") if train_config
# Load the credentials file, and place any valid settings into the train configuration
credentials = load_credentials(tm_config.host)
+
+ protocol = credentials[:train_protocol] || tm_config.protocol
+ train_config = tm_config.to_hash.select { |k| Train.options(protocol).key?(k) }
+ logger.trace("Using target mode options from #{ChefUtils::Dist::Infra::PRODUCT} config file: #{train_config.keys.join(", ")}") if train_config
+
if credentials
valid_settings = credentials.select { |k| Train.options(protocol).key?(k) }
valid_settings[:enable_password] = credentials[:enable_password] if credentials.key?(:enable_password)
@@ -126,7 +128,7 @@ module ChefConfig
# Train handles connection retries for us
Train.create(protocol, train_config)
rescue SocketError => e # likely a dns failure, not caught by train
- e.message.replace "Error connecting to #{train_config[:target]} - #{e.message}"
+ e.message.replace "Error connecting to #{train_config[:target]} via #{protocol} - #{e.message}"
raise e
rescue Train::PluginLoadError
logger.error("Invalid target mode protocol: #{protocol}")