chef / knife-windows

Plugin for Chef's knife tool for working with Windows nodes
Apache License 2.0
152 stars 110 forks source link

Named argument validation happens too late for bootstrap winrm #378

Closed mwrock closed 8 years ago

mwrock commented 8 years ago

This was originally filed in #323 but is in fact a separate issue so I am pasting it here:

Hi, I am still getting this issue when I try to bootstrap windows "node1" from windows workstation (Windows 8.1)

$ chef exec knife bootstrap windows winrm -N 192.168.33.93 --winrm-user Administrator --winrm-password 'XXXXX' --bootstrap-no-proxy -VV INFO: Using configuration from C:/Users/kolge/learn-chef/chef-repo/.chef/knife.rb DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key ca_trust_file and found value DEBUG: Looking for key winrm_user and found value Administrator DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key winrm_transport and found value plaintext DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key winrm_password and found value XXXXX DEBUG: Looking for key winrm_port and found value 5985 DEBUG: Looking for key session_timeout and found value 30 DEBUG: Looking for key session_timeout and found value 30 DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key winrm_transport and found value plaintext DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key winrm_transport and found value plaintext DEBUG: Looking for key winrm_authentication_protocol and found value negotiate DEBUG: Looking for key ca_trust_file and found value DEBUG: Looking for key ssl_peer_fingerprint and found value DEBUG: Looking for key ca_trust_file and found value C:/Users/kolge/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-windows-1.4.1/lib/chef/knife/winrm_knife_base.rb:69:in resolve_target_nodes': undefined methodsplit' for nil:NilClass (NoMethodError) from C:/Users/kolge/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-windows-1.4.1/lib/chef/knife/winrm_knife_base.rb:62:in configure_session' from C:/Users/kolge/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-windows-1.4.1/lib/chef/knife/bootstrap_windows_winrm.rb:51:inrun' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.10.24-universal-mingw32/lib/chef/knife.rb:421:in block in run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.10.24-universal-mingw32/lib/chef/local_mode.rb:44:inwith_server_connectivity' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.10.24-universal-mingw32/lib/chef/knife.rb:420:in run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.10.24-universal-mingw32/lib/chef/knife.rb:219:inrun' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.10.24-universal-mingw32/lib/chef/application/knife.rb:148:in run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.10.24-universal-mingw32/bin/knife:25:in' from C:/opscode/chefdk/bin/knife:61:in load' from C:/opscode/chefdk/bin/knife:61:in

' Is this fixed? How do I bootstrap a windows node? Please advise.

mwrock commented 8 years ago

Note that the error occurs because bootstrap_windows_winrm.rb runs:

        configure_session

        bootstrap

inside of its run method. This error occurs inside configure_session but we do arg validation in bootstrap

btm commented 8 years ago

https://github.com/chef/knife-windows/issues/323#issuecomment-236323300

This is actually a different bug. The bug for this issue results in NoMethodError: configure_proxy_environment_variables. The error reported by @samsonkolge is absolutely a bug and I'll open a separate issue to track it. However there is a workaround. The error you are getting is the result of the argument validation occuring too late. So the fact that you are missing the server argument is not producing an actionable error message. You can avoid this by using:

chef exec knife bootstrap windows winrm 192.168.33.93 -N 192.168.33.93 --winrm-user Administrator --winrm-password 'XXXXX' --bootstrap-no-proxy -VV

Note that the syntax of the bootstrap command is:

knife bootstrap windows winrm FQDN (options)

You are missing the required FQDN name which can be different (but does not have to be) from the node name passed in with -N

mwrock commented 8 years ago

fixed via #381

samsonkolge commented 7 years ago

@mwrock @dheerajd-msys Thanks for your diligent efforts.