Module: VagrantPlugins::Ansible::Cap::Guest::POSIX::AnsibleInstalled

Defined in:
lib/cap/guest/posix/ansible_installed.rb

Class Method Summary collapse

Class Method Details

.ansible_installed(machine, version) ⇒ true, false

Check if Ansible is installed (at the given version).

Returns:

  • (true, false)


10
11
12
13
14
15
16
17
18
# File 'lib/cap/guest/posix/ansible_installed.rb', line 10

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