Use the new Chef installation channel and options
This deprecates "prerelease", which will be removed in the next release.
This commit is contained in:
parent
43ef927628
commit
a90e6cfe4c
|
@ -5,11 +5,11 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
module Debian
|
module Debian
|
||||||
module ChefInstall
|
module ChefInstall
|
||||||
def self.chef_install(machine, version, prerelease, download_path)
|
def self.chef_install(machine, project, version, channel, options = {})
|
||||||
machine.communicate.sudo("apt-get update -y -qq")
|
machine.communicate.sudo("apt-get update -y -qq")
|
||||||
machine.communicate.sudo("apt-get install -y -qq curl")
|
machine.communicate.sudo("apt-get install -y -qq curl")
|
||||||
|
|
||||||
command = Omnibus.build_command(version, prerelease, download_path)
|
command = Omnibus.sh_command(project, version, channel, options)
|
||||||
machine.communicate.sudo(command)
|
machine.communicate.sudo(command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,13 +5,13 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
module OmniOS
|
module OmniOS
|
||||||
module ChefInstall
|
module ChefInstall
|
||||||
def self.chef_install(machine, version, prerelease, download_path)
|
def self.chef_install(machine, project, version, channel, options = {})
|
||||||
su_cmd = machine.config.solaris.suexec_cmd
|
su = machine.config.solaris.suexec_cmd
|
||||||
|
|
||||||
machine.communicate.execute("#{su_cmd} pkg list --no-refresh web/curl > /dev/null 2>&1 || pkg install -q --accept web/curl")
|
machine.communicate.execute("#{su} pkg list --no-refresh web/curl > /dev/null 2>&1 || pkg install -q --accept web/curl")
|
||||||
|
|
||||||
command = VagrantPlugins::Chef::Omnibus.build_command(version, prerelease, download_path)
|
command = Omnibus.sh_command(project, version, channel, options)
|
||||||
machine.communicate.execute(su_cmd + ' ' + command)
|
machine.communicate.execute("#{su} #{command}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,14 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
module Redhat
|
module Redhat
|
||||||
module ChefInstall
|
module ChefInstall
|
||||||
def self.chef_install(machine, version, prerelease, download_path)
|
def self.chef_install(machine, project, version, channel, options = {})
|
||||||
if dnf?(machine)
|
if dnf?(machine)
|
||||||
machine.communicate.sudo("dnf install -y -q curl")
|
machine.communicate.sudo("dnf install -y -q curl")
|
||||||
else
|
else
|
||||||
machine.communicate.sudo("yum install -y -q curl")
|
machine.communicate.sudo("yum install -y -q curl")
|
||||||
end
|
end
|
||||||
|
|
||||||
command = Omnibus.build_command(version, prerelease, download_path)
|
command = Omnibus.sh_command(project, version, channel, options)
|
||||||
machine.communicate.sudo(command)
|
machine.communicate.sudo(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,12 @@ module VagrantPlugins
|
||||||
# @return [String]
|
# @return [String]
|
||||||
attr_accessor :binary_env
|
attr_accessor :binary_env
|
||||||
|
|
||||||
|
# The name of the Chef project to install. This is "chef" for the Chef
|
||||||
|
# Client or "chefdk" for the Chef Development Kit. Other product names
|
||||||
|
# may be available as well.
|
||||||
|
# @return [String]
|
||||||
|
attr_accessor :product
|
||||||
|
|
||||||
# Install Chef on the system if it does not exist. Default is true.
|
# Install Chef on the system if it does not exist. Default is true.
|
||||||
# This is a trinary attribute (it can have three values):
|
# This is a trinary attribute (it can have three values):
|
||||||
#
|
#
|
||||||
|
@ -26,9 +32,11 @@ module VagrantPlugins
|
||||||
# @return [String, Symbol]
|
# @return [String, Symbol]
|
||||||
attr_accessor :log_level
|
attr_accessor :log_level
|
||||||
|
|
||||||
# Install a prerelease version of Chef.
|
# The channel from which to download Chef. Currently known values are
|
||||||
# @return [true, false]
|
# "current" and "stable", but more may be added in the future. The
|
||||||
attr_accessor :prerelease
|
# default is "current".
|
||||||
|
# @return [String]
|
||||||
|
attr_accessor :channel
|
||||||
|
|
||||||
# The version of Chef to install. If Chef is already installed on the
|
# The version of Chef to install. If Chef is already installed on the
|
||||||
# system, the installed version is compared with the requested version.
|
# system, the installed version is compared with the requested version.
|
||||||
|
@ -52,25 +60,38 @@ module VagrantPlugins
|
||||||
# @return [String]
|
# @return [String]
|
||||||
attr_accessor :installer_download_path
|
attr_accessor :installer_download_path
|
||||||
|
|
||||||
|
# @deprecated
|
||||||
|
def prerelease=(value)
|
||||||
|
STDOUT.puts <<-EOH
|
||||||
|
[DEPRECATED] The configuration `chef.prerelease' has been deprecated. Please use
|
||||||
|
`chef.channel' instead. The default value for channel is "current", which
|
||||||
|
includes prelease versions of Chef Client and the Chef Development Kit. You can
|
||||||
|
probably just remove the `prerelease' setting from your Vagrantfile and things
|
||||||
|
will continue working as expected.
|
||||||
|
EOH
|
||||||
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super
|
super
|
||||||
|
|
||||||
@binary_path = UNSET_VALUE
|
@binary_path = UNSET_VALUE
|
||||||
@binary_env = UNSET_VALUE
|
@binary_env = UNSET_VALUE
|
||||||
|
@product = UNSET_VALUE
|
||||||
@install = UNSET_VALUE
|
@install = UNSET_VALUE
|
||||||
@log_level = UNSET_VALUE
|
@log_level = UNSET_VALUE
|
||||||
@prerelease = UNSET_VALUE
|
@channel = UNSET_VALUE
|
||||||
@version = UNSET_VALUE
|
@version = UNSET_VALUE
|
||||||
@installer_download_path = UNSET_VALUE
|
@installer_download_path = UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
@binary_path = nil if @binary_path == UNSET_VALUE
|
@binary_path = nil if @binary_path == UNSET_VALUE
|
||||||
@binary_env = nil if @binary_env == UNSET_VALUE
|
@binary_env = nil if @binary_env == UNSET_VALUE
|
||||||
@install = true if @install == UNSET_VALUE
|
@product = "chef" if @product == UNSET_VALUE
|
||||||
@log_level = :info if @log_level == UNSET_VALUE
|
@install = true if @install == UNSET_VALUE
|
||||||
@prerelease = false if @prerelease == UNSET_VALUE
|
@log_level = :info if @log_level == UNSET_VALUE
|
||||||
@version = :latest if @version == UNSET_VALUE
|
@channel = "current" if @channel == UNSET_VALUE
|
||||||
|
@version = :latest if @version == UNSET_VALUE
|
||||||
@installer_download_path = nil if @installer_download_path == UNSET_VALUE
|
@installer_download_path = nil if @installer_download_path == UNSET_VALUE
|
||||||
|
|
||||||
# Make sure the install is a symbol if it's not a boolean
|
# Make sure the install is a symbol if it's not a boolean
|
||||||
|
|
|
@ -3,10 +3,11 @@ module VagrantPlugins
|
||||||
class Installer
|
class Installer
|
||||||
def initialize(machine, options = {})
|
def initialize(machine, options = {})
|
||||||
@machine = machine
|
@machine = machine
|
||||||
@version = options.fetch(:version, :latest)
|
@product = options.fetch(:product)
|
||||||
@prerelease = options.fetch(:prerelease, :latest)
|
@channel = options.fetch(:channel)
|
||||||
@force = options.fetch(:force, false)
|
@version = options.fetch(:version)
|
||||||
@download_path = options.fetch(:download_path, nil)
|
@force = options.fetch(:force)
|
||||||
|
@options = options.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
# This handles verifying the Chef installation, installing it if it was
|
# This handles verifying the Chef installation, installing it if it was
|
||||||
|
@ -28,7 +29,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
@machine.ui.detail(I18n.t("vagrant.chef_installing",
|
@machine.ui.detail(I18n.t("vagrant.chef_installing",
|
||||||
version: @version.to_s))
|
version: @version.to_s))
|
||||||
@machine.guest.capability(:chef_install, @version, @prerelease, @download_path)
|
@machine.guest.capability(:chef_install, @product, @version, @channel, @options)
|
||||||
|
|
||||||
if !@machine.guest.capability(:chef_installed, @version)
|
if !@machine.guest.capability(:chef_installed, @version)
|
||||||
raise Provisioner::Base::ChefError, :install_failed
|
raise Provisioner::Base::ChefError, :install_failed
|
||||||
|
|
|
@ -42,9 +42,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
@logger.info("Checking for Chef installation...")
|
@logger.info("Checking for Chef installation...")
|
||||||
installer = Installer.new(@machine,
|
installer = Installer.new(@machine,
|
||||||
force: config.install == :force,
|
product: config.product,
|
||||||
version: config.version,
|
channel: config.channel,
|
||||||
prerelease: config.prerelease,
|
version: config.version,
|
||||||
|
force: config.install == :force,
|
||||||
download_path: config.installer_download_path
|
download_path: config.installer_download_path
|
||||||
)
|
)
|
||||||
installer.ensure_installed
|
installer.ensure_installed
|
||||||
|
|
|
@ -23,6 +23,13 @@ describe VagrantPlugins::Chef::Config::Base do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#product" do
|
||||||
|
it "defaults to \"chef\"" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.product).to eq("chef")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#install" do
|
describe "#install" do
|
||||||
it "defaults to true" do
|
it "defaults to true" do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
|
@ -49,10 +56,18 @@ describe VagrantPlugins::Chef::Config::Base do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#prerelease" do
|
describe "#channel" do
|
||||||
it "defaults to true" do
|
it "defaults to \"current\"" do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
expect(subject.prerelease).to be(false)
|
expect(subject.channel).to eq("current")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#prerelease" do
|
||||||
|
it "should not exist in Vagrant 1.9" do
|
||||||
|
if Vagrant::VERSION >= "1.9"
|
||||||
|
raise "This option should be removed!"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,18 @@ their purpose.
|
||||||
- `installer_download_path` (string) - The path where the Chef installer will be
|
- `installer_download_path` (string) - The path where the Chef installer will be
|
||||||
downloaded to. This option is only honored if the `install` attribute is
|
downloaded to. This option is only honored if the `install` attribute is
|
||||||
`true` or `"force"`. The default value is to use the path provided by Chef's
|
`true` or `"force"`. The default value is to use the path provided by Chef's
|
||||||
Omnibus installer, which varies between releases.
|
Omnibus installer, which varies between releases. This value has no effect on
|
||||||
|
Windows because Chef's omnibus installer lacks the option on Windows.
|
||||||
|
|
||||||
- `log_level` (string) - The Chef log level. See the Chef docs for acceptable
|
- `log_level` (string) - The Chef log level. See the Chef docs for acceptable
|
||||||
values.
|
values.
|
||||||
|
|
||||||
- `prerelease` (boolean) - Install a prerelease version of Chef. The default
|
- `product` (string) - The name of the Chef product to install. The default
|
||||||
value is false.
|
value is "chef", which corresponds to the Chef Client. You can also specify
|
||||||
|
"chefdk", which will install the Chef Development Kit.
|
||||||
|
|
||||||
|
- `channel` (string) - The release channel from which to pull the Chef Client
|
||||||
|
or the Chef Development Kit. The default value is `"current"`.
|
||||||
|
|
||||||
- `version` (string) - The version of Chef to install on the guest. If Chef is
|
- `version` (string) - The version of Chef to install on the guest. If Chef is
|
||||||
already installed on the system, the installed version is compared with the
|
already installed on the system, the installed version is compared with the
|
||||||
|
|
Loading…
Reference in New Issue