chef / knife-windows

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

Chef installation directory is hard-coded to C:\chef #360

Closed ZillaG closed 7 years ago

ZillaG commented 8 years ago

I want to be able to install Chef on my Windows nodes to a different disk, say E:\, but the function

def bootstrap_directory()
  bootstrap_directory = "C:\\Chef"
end

hard-codes it to C:\Chef. It'd be cool if we can do this, in our knife.rb file

knife[:bootstrap_directory] = "E:\\Chef"

for example (but of course qualify it with OS type)

mwrock commented 8 years ago

Out of curiosity I checked chef core to see where the bootstrap directory lives on linux bootstraps. Its also hardcoded to /opt/chef. That doesn't make this "right". I can definitely see value here.

ssafron commented 8 years ago

One workaround is to write a custom bootstrap template to substitute the bootstrap_directory. Here is an example of the changes to the standard windows bootstrap template to accept a "bootstrap_directory" attribute in the -j attribute of the knife bootstrap command .

<% if @config[:first_boot_attributes]['bootstrap_directory'] -%>
<% bootstrap_directory = @config[:first_boot_attributes]['bootstrap_directory'] -%>
<% else -%>
<% bootstrap_directory = "C:/chef" -%>
<% end -%>

   . . .

<% #customize client.rb file to sub out the old bootstrap directory -%>
<%  
client_rb = config_content
client_rb.gsub!(/c:\/chef\//i, bootstrap_directory + "/")
puts client_rb
-%>
> <%= bootstrap_directory %>\client.rb (
 <%= client_rb %>
)

  . . .

<% # customize start_chef to sub out the old bootstrap directory -%>
<%
new_start_chef = start_chef
new_start_chef.gsub!(/c:\/chef\//i, bootstrap_directory + "/")
-%>
<%= new_start_chef %>
pavelsavara commented 8 years ago

The other files hardcoding windows path to C:\ are

f:\opscode\chefdk\embedded\lib\ruby\site_ruby\devkit.rb
f:\opscode\chefdk\embedded\lib\ruby\site_ruby\2.1.0\rubygems\defaults\operating_system.rb
f:\opscode\chefdk\embedded\lib\ruby\gems\2.1.0\gems\knife-windows-1.4.1\lib\chef\knife\core\windows_bootstrap_context.rb

Another possible workaround is symlink junction.exe c:\opscode f:\opscode

btm commented 8 years ago

There have been a number of issues identified over time with changing the installation path and drive, see https://github.com/chef/chef/issues/1512 for more information.

cheeseplus commented 7 years ago

Closing this one out as the core issue is the linked https://github.com/chef/chef/issues/1512 and not a knife-windows specific issue.