Collin McNeese 0085124cd8
Updates chef_installed variable names to be more functional
Signed-off-by: Collin McNeese <cmcneese@chef.io>
2021-10-24 12:32:37 -05:00

22 lines
739 B
Ruby

module VagrantPlugins
module Chef
module Cap
module Windows
module ChefInstalled
# Check if Chef is installed at the given version.
# @return [true, false]
def self.chef_installed(machine, product, version)
verify_bin = product == 'chef-workstation' ? 'chef' : 'chef-client'
if version != :latest
command = 'if ((&' + verify_bin + ' --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }'
else
command = 'if ((&' + verify_bin + ' --version) -Match "Chef*"){ exit 0 } else { exit 1 }'
end
machine.communicate.test(command, sudo: true)
end
end
end
end
end
end