vagrant/plugins/provisioners/ansible/cap/guest/posix/ansible_installed.rb

26 lines
611 B
Ruby
Raw Normal View History

module VagrantPlugins
module Ansible
module Cap
module Guest
module POSIX
module AnsibleInstalled
# Check if Ansible is installed (at the given version).
# @return [true, false]
def self.ansible_installed(machine, version)
command = 'test -x "$(command -v ansible)"'
if !version.empty?
command << "&& ansible --version | grep 'ansible #{version}'"
end
machine.communicate.test(command, sudo: false)
end
end
end
end
end
end
end