Class: VagrantPlugins::PuppetInstall::Action::ReadPuppetVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-puppet-install/action/read_puppet_version.rb

Overview

This action will extract the installed version of Puppet installed on the guest. The resulting version will exist in the :installed_puppet_version key in the environment.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ReadPuppetVersion

Returns a new instance of ReadPuppetVersion.



26
27
28
# File 'lib/vagrant-puppet-install/action/read_puppet_version.rb', line 26

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-puppet-install/action/read_puppet_version.rb', line 30

def call(env)
  env[:installed_puppet_version] = nil
  env[:machine].communicate.tap do |comm|
    # Execute it with sudo
    comm.sudo(puppet_version_command) do |type, data|
      if [:stderr, :stdout].include?(type)
        env[:installed_puppet_version] = data.chomp
      end
    end
  end
  @app.call(env)
end