Sha256: 205550563a15c6e03eb3e707f808a39462e428dd1c843f2f6442d4972b4486de

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

module VagrantPlugins
  module Omnibus
    module Action
      # @author Seth Chisamore <schisamo@opscode.com>
      #
      # This action will extract the installed version of Chef installed on the
      # guest. The resulting version will exist in the `:installed_chef_version`
      # key in the environment.
      class ReadChefVersion
        def initialize(app, env)
          @app = app
        end

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

        private

        def chef_version_command
          <<-CHEF_VERSION
echo $(chef-solo --v | awk "{print \\$2}" || "")
          CHEF_VERSION
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-omnibus-1.0.0 lib/vagrant-omnibus/action/read_chef_version.rb