Add chef_install(ed?) guest capability for freebsd

This commit is contained in:
Anand Suresh 2017-04-04 22:10:02 -07:00
parent 147b7e3275
commit 30f4eb62ea
3 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,18 @@
require_relative "../../omnibus"
module VagrantPlugins
module Chef
module Cap
module FreeBSD
module ChefInstall
def self.chef_install(machine, project, version, channel, options = {})
machine.communicate.sudo("pkg install -y -qq curl bash")
command = Omnibus.sh_command(project, version, channel, options)
machine.communicate.sudo(command)
end
end
end
end
end
end

View File

@ -0,0 +1,22 @@
module VagrantPlugins
module Chef
module Cap
module FreeBSD
module ChefInstalled
# Check if Chef is installed at the given version.
# @return [true, false]
def self.chef_installed(machine, product, version)
knife = "/opt/#{product}/bin/knife"
command = "test -x #{knife}"
if version != :latest
command << "&& #{knife} --version | grep 'Chef: #{version}'"
end
machine.communicate.test(command, sudo: true)
end
end
end
end
end
end

View File

@ -58,6 +58,16 @@ module VagrantPlugins
Cap::Debian::ChefInstall
end
guest_capability(:freebsd, :chef_install) do
require_relative "cap/freebsd/chef_install"
Cap::FreeBSD::ChefInstall
end
guest_capability(:freebsd, :chef_installed) do
require_relative "cap/freebsd/chef_installed"
Cap::FreeBSD::ChefInstalled
end
guest_capability(:linux, :chef_installed) do
require_relative "cap/linux/chef_installed"
Cap::Linux::ChefInstalled