Prior to this commit, the chef_installed capability was looking for a string that has recently changed in newer versions of chef. This commit fixes that by instead just looking for the right version that was configured for the chef client, rather than the specific string that could change again in the future.
21 lines
633 B
Ruby
21 lines
633 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)
|
|
if version != :latest
|
|
command = 'if ((&knife --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }'
|
|
else
|
|
command = 'if ((&knife --version) -Match "Chef*"){ exit 0 } else { exit 1 }'
|
|
end
|
|
machine.communicate.test(command, sudo: true)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|