-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed issues facing while bootstrapping the node using ssh config file. #11531
Fixed issues facing while bootstrapping the node using ssh config file. #11531
Conversation
59e8744
to
2725a35
Compare
@tas50 and @lamont-granquist Please review this PR. Thanks!! |
|
||
if config[:sudo] | ||
# While using ssh config file user might present in ssh file | ||
user = config[:user] || ssh_config_for_host(config[:host])[:user] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already available in @config[:user], which we should use instead of re-doing override parsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcparadise, This change will resolve user nil(@config[:user]) issue when we have added user in ssh_config file instead of adding it in bootstrap command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@config contains the merged results of all config, including the user's ssh config as provided by Net::SSH.config_for_host
. You can see this in transport_config
[1], where it also merges in missing_opts_from_ssh_config
defined later in the same file. This merge currently accepts SSH_CONFIG_OVERRIDE_KEYS
, which are user
, port
, and proxy
.
[1] https://github.com/chef/chef/blob/master/knife/lib/chef/knife/bootstrap/train_connector.rb#L225
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @marcparadise, will update according to it.
knife/lib/chef/knife/bootstrap.rb
Outdated
@@ -974,13 +974,17 @@ def ssh_identity_opts | |||
# Reference: https://github.com/chef/chef/blob/master/lib/chef/knife/ssh.rb#L272 | |||
opts[:keys_only] = config.key?(:connection_password) == false | |||
else | |||
opts[:key_files] = [] | |||
opts[:key_files] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was this intended to fix?
In train, a value of nil
for key_files
will get converted to []
. Given that, this change and the one below /should/ have a net of no effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcparadise, in train nil
for key_files
is not converting to []
.
For reference: https://github.com/inspec/train/blob/62a8b1e0b5f6e2cc88b0ab2e4e9101c571bc99df/lib/train.rb#L179
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is used for train's CLI usage, IIRC; that is not the path we take.
Our path starts in TrainConnector.connection
, which invokes Train.create
[1] This returns a new instance of Train::Transports::SSH
[2]. We then call instance.connection
to retrieve the connection object. connection
calls validate_options
[3] which in turn initializes key_files
as Array(options[:key_files])
[4]. When key_files
is nil, that will evaluate to []
.
[1] https://github.com/chef/chef/blob/master/knife/lib/chef/knife/bootstrap/train_connector.rb#L54
[2] https://github.com/inspec/train/blob/master/lib/train.rb#L20
[3] https://github.com/inspec/train/blob/master/lib/train/transports/ssh.rb#L79.
[4] https://github.com/inspec/train/blob/master/lib/train/transports/ssh.rb#L109
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
…ts_in missing user and port variables Signed-off-by: sanga17 <sausekar@msystechnologies.com>
c3e5359
to
c654e76
Compare
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
Signed-off-by: sanga17 sausekar@msystechnologies.com
Description
Fixed issues facing while bootstrapping the node using ssh config file.
Related Issue
Fixed: 1) #7053
2) https://github.com/chef/customer-bugs/issues/271
Types of changes
Checklist: