Install knife windows offline


#1

HI,

I want to install knife windows. But my server has no internet connection .

So I want to install it offline. Can anyone tell me how can we do this.

Regards,
Ramadurai


#2

You would approach this as you would with any other gem. Tools like artifactory and nexus can provide more sophisticated means to cache rubygems.org to a internal repository. However, a rudimentary approach would be to download the gem from a machine that has internet access:

gem fetch knife-windows

Then copy the downloaded .gem file to your server and install via:

gem install knife-windows-1.5.0.gem

That all said, typically knife-windows is a tool used on an administrator’s workstation and not a server node, but if that workstation has no internet connectivity, the above certainly applies.


#3

Thank you.
I have followed what you suggested. But am getting below error.

WARNING: Unable to pull data from ‘https://rubygems.org/’: Errno::ETIMEDOUT: A connection attempt failed because the co
nnected party did not properly respond after a period of time, or established connection failed because connected host h
as failed to respond. - connect(2) for “api.rubygems.org” port 443 (https://api.rubygems.org/specs.4.8.gz)
1 gem installed

Here am using windows power shell . am not using Chef DK. Whenever trying to run kinfe -help , am not getting in WINRM commands in that list.

Can you help me out.


#4

Try adding --local to the gem install command. Also have a look at http://help.rubygems.org/kb/rubygems/installing-gems-with-no-network


#5

Download knife windows. Keep it in some local directory and execute following command.

gem install --force --local *.gem

Hope this will help.


#6

Thank you . Its working for me…


#7

I managed to install it: gem install --force --local *.gem
Successfully installed knife-windows-1.6.0
1 gem installed
but when i try to bootstrap a windows server i get this error, any idea how to resolve it?
/opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:310:in to_specs': Could not find 'winrm-elevated' (~> 1.0) - did find: [winrm-elevated-0.4.0] (Gem::MissingSpecVersionError) Checked in 'GEM_PATH=/root/.chefdk/gem/ruby/2.1.0:/opt/chefdk/embedded/lib/ruby/gems/2.1.0', executegem envfor more information from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1439:inblock in activate_dependencies’
from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1428:in each' from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1428:inactivate_dependencies’
from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1410:in activate' from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:220:inrescue in try_activate’
from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:213:in try_activate' from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:inrescue in require’
from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:40:in require' from /root/.chefdk/gem/ruby/2.1.0/gems/knife-windows-1.6.0/lib/chef/knife/windows_listener_create.rb:19:in<top (required)>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife/core/subcommand_loader.rb:100:in load' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife/core/subcommand_loader.rb:100:inblock in load_commands’
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife/core/subcommand_loader.rb:100:in each' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife/core/subcommand_loader.rb:100:inload_commands’
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife/core/subcommand_loader.rb:110:in load_command' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife/core/subcommand_loader.rb:124:incommand_class_from’
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife.rb:153:in subcommand_class_from' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/knife.rb:214:inrun’
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/lib/chef/application/knife.rb:148:in run' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15/bin/knife:25:in<top (required)>'
from /opt/chefdk/bin/knife:52:in load' from /opt/chefdk/bin/knife:52:in'[details=Summary][details=Summary][details=Summary]This text will be hidden[/details][/details][/details]


#8

It looks like the dependencies you have are not compatible with knife-windows 1.6.0 but are from an older version. You will want to ensure that the other gem files you have are updated and met the constraints of knife-windows 1.6.0.


#9

Thanks! i just managed to install them all:
gem install --force --local *.gem
Successfully installed winrm-fs-1.0.0
Successfully installed knife-windows-1.6.0
Successfully installed rubyntlm-0.6.1
Successfully installed winrm-2.1.0
Successfully installed winrm-elevated-1.0.1
Successfully installed winrm-fs-1.0.0
6 gems installed
error is gone but i have another one:

ERROR: Network Error: Connection refused - connect(2) for 10.5.83.15:22
Check your knife configuration and network settings

I think its the port on the windows node, working on it.


#10

What’s the knife command you used?


#11

knife bootstrap 10.5.83.15 -N HOSTNAME


#12

That doesn’t leverage knife-windows but just uses the core knife bootstrap via ssh(port 22). Have a look at the knife-windows readme for example usages of knife bootstrap windows.


#13

I used this command: knife bootstrap windows winrm IP -x ‘mydomain\username’ -N HOST
but the bootstrapping fails at this point:
10.5.83.15 powershell.exe -ExecutionPolicy Unrestricted -InputFormat None -NoProfile -NonInteractive -File C:\chef\wget.ps1 “https://www.chef.io/chef/download?p=windows&pv=2012&m=x86_64&DownloadContext=PowerShell&v=12” "C:\Users\user\AppData\Local\Temp\chef-client-latest.msi"
10.5.83.15 Exception calling “DownloadFile” with “2” argument(s): "Unable to connect to
10.5.83.15 the remote server"
10.5.83.15 At C:\chef\wget.ps1:14 char:1
10.5.83.15 + $webClient.DownloadFile($remoteUrl, $localPath);
10.5.83.15 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10.5.83.15 + CategoryInfo : NotSpecified: (:slight_smile: [], MethodInvocationException
10.5.83.15 + FullyQualifiedErrorId : WebException
10.5.83.15
10.5.83.15 Warning: Failed to download “https://www.chef.io/chef/download?p=windows&pv=2012&m=x86_64&DownloadContext=PowerShell&v=12” to "C:\Users\user\AppData\Local\Temp\chef-client-latest.msi"
10.5.83.15 Warning: Retrying download with cscript …
10.5.83.15 Failed download: download completed, but downloaded file not found
10.5.83.15 C:\chef\wget.vbs(47, 1) msxml3.dll: The operation timed out
10.5.83.15
10.5.83.15
10.5.83.15 Failed download: download completed, but downloaded file not found
10.5.83.15 Exiting without bootstrapping due to download failure.
ERROR: Failed to execute command on 10.5.83.15 return code 1

Any idea why? the chef-client is installed on the windows Node.


#14

If chef is already installed on the node, you can bypass the chef client download/install by adding the --bootstrap-install-command argument and passing in a no-op commnd like exit 0.


#15

Thank u!!! it worked!
knife bootstrap --bootstrap-install-command windows winrm IP -x ‘mydomain\username’ -N HOST