diff options
author | Tim Smith <tsmith@chef.io> | 2021-10-14 10:52:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 10:52:03 -0700 |
commit | 3ce0bef5abb97593b8c42fbadc3f07240b047fae (patch) | |
tree | 3242821762be5a2aff024f6bd6059c4cf2a7e5c9 /chef-config | |
parent | b798363675254473e1f222af820aa5996fbb9fa2 (diff) | |
parent | 4aad39c3c41f5a0a4459fc43c376dc33f00446d6 (diff) | |
download | chef-3ce0bef5abb97593b8c42fbadc3f07240b047fae.tar.gz |
Merge pull request #12151 from tecracer-theinen/theinen/target-protocol-in-credentials
Allow specifying transport protocol in RFC099 credential files
Diffstat (limited to 'chef-config')
-rw-r--r-- | chef-config/lib/chef-config/mixin/train_transport.rb | 10 |
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..3bd56650b2 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[:transport_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}") |