Allow Chef to install on Windows
This commit is contained in:
parent
a90e6cfe4c
commit
c30467a6f9
|
@ -0,0 +1,16 @@
|
|||
require_relative "../../omnibus"
|
||||
|
||||
module VagrantPlugins
|
||||
module Chef
|
||||
module Cap
|
||||
module Windows
|
||||
module ChefInstall
|
||||
def self.chef_install(machine, project, version, channel, options = {})
|
||||
command = Omnibus.ps_command(project, version, channel, options)
|
||||
machine.communicate.sudo(command)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,32 +1,39 @@
|
|||
module VagrantPlugins
|
||||
module Chef
|
||||
module Omnibus
|
||||
OMNITRUCK = "https://www.chef.io/chef/install.sh".freeze
|
||||
|
||||
# Read more about the Omnibus installer here:
|
||||
# https://docs.getchef.com/install_omnibus.html
|
||||
def build_command(version, prerelease = false, download_path = nil)
|
||||
command = "curl -sL #{OMNITRUCK} | sudo bash"
|
||||
#
|
||||
# https://docs.chef.io/install_omnibus.html
|
||||
#
|
||||
module Omnibus
|
||||
OMNITRUCK = "https://omnitruck.chef.io".freeze
|
||||
|
||||
if prerelease || version != :latest || download_path != nil
|
||||
command << " -s --"
|
||||
end
|
||||
|
||||
if prerelease
|
||||
command << " -p"
|
||||
end
|
||||
def sh_command(project, version, channel, options = {})
|
||||
command = "curl -sL #{OMNITRUCK}/install.sh | sudo bash"
|
||||
command << " -s -- -P \"#{project}\" -c \"#{channel}\""
|
||||
|
||||
if version != :latest
|
||||
command << " -v \"#{version}\""
|
||||
end
|
||||
|
||||
if download_path
|
||||
command << " -d \"#{download_path}\""
|
||||
if options[:download_path]
|
||||
command << " -d \"#{options[:download_path]}\""
|
||||
end
|
||||
|
||||
command
|
||||
end
|
||||
module_function :build_command
|
||||
module_function :sh_command
|
||||
|
||||
def ps_command(project, version, channel, options = {})
|
||||
command = ". { iwr -useb #{OMNITRUCK}/install.ps1 } | iex; install"
|
||||
command << " -project '#{project}' -channel '#{channel}'"
|
||||
|
||||
if version != :latest
|
||||
command << " -version '#{version}'"
|
||||
end
|
||||
|
||||
command
|
||||
end
|
||||
module_function :ps_command
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,29 +53,14 @@ module VagrantPlugins
|
|||
Provisioner::ChefZero
|
||||
end
|
||||
|
||||
guest_capability(:linux, :chef_installed) do
|
||||
require_relative "cap/linux/chef_installed"
|
||||
Cap::Linux::ChefInstalled
|
||||
end
|
||||
|
||||
guest_capability(:windows, :chef_installed) do
|
||||
require_relative "cap/windows/chef_installed"
|
||||
Cap::Windows::ChefInstalled
|
||||
end
|
||||
|
||||
guest_capability(:debian, :chef_install) do
|
||||
require_relative "cap/debian/chef_install"
|
||||
Cap::Debian::ChefInstall
|
||||
end
|
||||
|
||||
guest_capability(:redhat, :chef_install) do
|
||||
require_relative "cap/redhat/chef_install"
|
||||
Cap::Redhat::ChefInstall
|
||||
end
|
||||
|
||||
guest_capability(:omnios, :chef_installed) do
|
||||
require_relative "cap/omnios/chef_installed"
|
||||
Cap::OmniOS::ChefInstalled
|
||||
guest_capability(:linux, :chef_installed) do
|
||||
require_relative "cap/linux/chef_installed"
|
||||
Cap::Linux::ChefInstalled
|
||||
end
|
||||
|
||||
guest_capability(:omnios, :chef_install) do
|
||||
|
@ -83,6 +68,25 @@ module VagrantPlugins
|
|||
Cap::OmniOS::ChefInstall
|
||||
end
|
||||
|
||||
guest_capability(:omnios, :chef_installed) do
|
||||
require_relative "cap/omnios/chef_installed"
|
||||
Cap::OmniOS::ChefInstalled
|
||||
end
|
||||
|
||||
guest_capability(:redhat, :chef_install) do
|
||||
require_relative "cap/redhat/chef_install"
|
||||
Cap::Redhat::ChefInstall
|
||||
end
|
||||
|
||||
guest_capability(:windows, :chef_install) do
|
||||
require_relative "cap/windows/chef_install"
|
||||
Cap::Windows::ChefInstall
|
||||
end
|
||||
|
||||
guest_capability(:windows, :chef_installed) do
|
||||
require_relative "cap/windows/chef_installed"
|
||||
Cap::Windows::ChefInstalled
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,53 +3,44 @@ require_relative "../../../base"
|
|||
require Vagrant.source_root.join("plugins/provisioners/chef/omnibus")
|
||||
|
||||
describe VagrantPlugins::Chef::Omnibus do
|
||||
let(:prefix) { "curl -sL #{described_class.const_get(:OMNITRUCK)}" }
|
||||
describe "#sh_command" do
|
||||
it "includes the project name" do
|
||||
command = described_class.sh_command("chef", nil, "stable")
|
||||
expect(command).to include %|-P "chef"|
|
||||
end
|
||||
|
||||
let(:version) { :latest }
|
||||
let(:prerelease) { false }
|
||||
let(:download_path) { nil }
|
||||
it "includes the channel" do
|
||||
command = described_class.sh_command("chef", nil, "stable")
|
||||
expect(command).to include %|-c "stable"|
|
||||
end
|
||||
|
||||
let(:build_command) { described_class.build_command(version, prerelease, download_path) }
|
||||
it "includes the version" do
|
||||
command = described_class.sh_command("chef", "1.2.3", "stable")
|
||||
expect(command).to include %|-v "1.2.3"|
|
||||
end
|
||||
|
||||
context "when prerelease is given" do
|
||||
let(:prerelease) { true }
|
||||
|
||||
it "returns the correct command" do
|
||||
expect(build_command).to eq("#{prefix} | sudo bash -s -- -p")
|
||||
it "includes the download path" do
|
||||
command = described_class.sh_command("chef", "1.2.3", "stable",
|
||||
download_path: "/some/path",
|
||||
)
|
||||
expect(command).to include %|-d "/some/path"|
|
||||
end
|
||||
end
|
||||
|
||||
context "when download_path is given" do
|
||||
let(:download_path) { '/tmp/path/to/omnibuses' }
|
||||
|
||||
it "returns the correct command" do
|
||||
expect(build_command).to eq("#{prefix} | sudo bash -s -- -d \"/tmp/path/to/omnibuses\"")
|
||||
end
|
||||
describe "#ps_command" do
|
||||
it "includes the project name" do
|
||||
command = described_class.ps_command("chef", nil, "stable")
|
||||
expect(command).to include %|-project 'chef'|
|
||||
end
|
||||
|
||||
context "when version is :latest" do
|
||||
let(:version) { :latest }
|
||||
|
||||
it "returns the correct command" do
|
||||
expect(build_command).to eq("#{prefix} | sudo bash")
|
||||
end
|
||||
it "includes the channel" do
|
||||
command = described_class.ps_command("chef", nil, "stable")
|
||||
expect(command).to include %|-channel 'stable'|
|
||||
end
|
||||
|
||||
context "when version is a string" do
|
||||
let(:version) { "1.2.3" }
|
||||
|
||||
it "returns the correct command" do
|
||||
expect(build_command).to eq("#{prefix} | sudo bash -s -- -v \"1.2.3\"")
|
||||
end
|
||||
end
|
||||
|
||||
context "when prerelease and version and download_path are given" do
|
||||
let(:version) { "1.2.3" }
|
||||
let(:prerelease) { true }
|
||||
let(:download_path) { "/some/path" }
|
||||
|
||||
it "returns the correct command" do
|
||||
expect(build_command).to eq("#{prefix} | sudo bash -s -- -p -v \"1.2.3\" -d \"/some/path\"")
|
||||
it "includes the version" do
|
||||
command = described_class.ps_command("chef", "1.2.3", "stable")
|
||||
expect(command).to include %|-version '1.2.3'|
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue