Skip to content

Commit

Permalink
adding defaults for chef_omnibus_root for windows and unix-like/linux…
Browse files Browse the repository at this point in the history
… systems

This work patches test-kitchen#923 so that the issue will stop bugging people, and we can discuss implementing mixlib-install but that has downstream affects against cinc.
  • Loading branch information
tarcinil committed Jan 30, 2020
1 parent 67d45d9 commit 40fa9f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/kitchen/provisioner/chef_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Provisioner
class ChefBase < Base
default_config :require_chef_omnibus, true
default_config :chef_omnibus_url, "https://omnitruck.chef.io/install.sh"
default_config :chef_omnibus_root,"/opt/chef"
default_config :chef_omnibus_install_options, nil
default_config :chef_license, nil
default_config :run_list, []
Expand Down Expand Up @@ -341,6 +342,7 @@ def last_exit_code
# @api private
def install_options
add_omnibus_directory_option if instance.driver.cache_directory
chef_omnibus_root
project = /\s*-P (\w+)\s*/.match(config[:chef_omnibus_install_options])
{
omnibus_url: config[:chef_omnibus_url],
Expand Down Expand Up @@ -552,6 +554,12 @@ def omnibus_dir_option
windows_os? ? "-download_directory" : "-d"
end

# @return [String] Correct config when running in Windows,
# @api private
def omnibus_root_dir
config[:chef_omnibus_root] = windows_os? ? "C:\opscode" : config[:chef_omnibus_root]
end

def install_from_file(command)
install_file = "/tmp/chef-installer.sh"
script = ["cat > #{install_file} <<\"EOL\""]
Expand Down
10 changes: 10 additions & 0 deletions spec/kitchen/provisioner/chef_base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def calculate_path(path, _opts = {})
.must_equal "https://omnitruck.chef.io/install.sh"
end

it ":chef_omnibus_root has a default" do
provisioner[:chef_omnibus_root]
.must_equal "/opt/chef"
end

it ":chef_metadata_url defaults to nil" do
provisioner[:chef_metadata_url].must_be_nil
end
Expand All @@ -73,6 +78,11 @@ def calculate_path(path, _opts = {})
provisioner[:chef_omnibus_url]
.must_equal "https://omnitruck.chef.io/install.sh"
end

it ":chef_omnibus_root has a default" do
provisioner[:chef_omnibus_root]
.must_equal "C:\opscode"
end
end

it ":require_chef_omnibus defaults to true" do
Expand Down

0 comments on commit 40fa9f0

Please sign in to comment.