Sha256: 3e5278c389a64040f58fe522b0f00b059b84a882f6f452defe21cfd882202687

Contents?: true

Size: 1.6 KB

Versions: 15

Compression:

Stored size: 1.6 KB

Contents

module VagrantPlugins
  module Chef
    class Installer
      def initialize(machine, options = {})
        @machine    = machine
        @product    = options.fetch(:product)
        @channel    = options.fetch(:channel)
        @version    = options.fetch(:version)
        @force      = options.fetch(:force)
        @options    = options.dup
      end

      # This handles verifying the Chef installation, installing it if it was
      # requested, and so on. This method will raise exceptions if things are
      # wrong.
      def ensure_installed
        # If the guest cannot check if Chef is installed, just exit printing a
        # warning...
        if !@machine.guest.capability?(:chef_installed)
          @machine.ui.warn(I18n.t("vagrant.chef_cant_detect"))
          return
        end

        if !should_install_chef?
          @machine.ui.info(I18n.t("vagrant.chef_already_installed",
            version: @version.to_s))
          return
        end

        @machine.ui.detail(I18n.t("vagrant.chef_installing",
          version: @version.to_s))
        @machine.guest.capability(:chef_install, @product, @version, @channel, @options)

        if !@machine.guest.capability(:chef_installed, @product, @version)
          raise Provisioner::Base::ChefError, :install_failed
        end
      end

      # Determine if Chef should be installed. Chef is installed if the "force"
      # option is given or if the guest does not have Chef installed at the
      # proper version.
      def should_install_chef?
        @force || !@machine.guest.capability(:chef_installed, @product, @version)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
vagrant-unbundled-1.9.7.1 plugins/provisioners/chef/installer.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/provisioners/chef/installer.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/provisioners/chef/installer.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/provisioners/chef/installer.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/provisioners/chef/installer.rb
vagrant-unbundled-1.9.5.1 plugins/provisioners/chef/installer.rb
vagrant-unbundled-1.9.1.1 plugins/provisioners/chef/installer.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/provisioners/chef/installer.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/provisioners/chef/installer.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/provisioners/chef/installer.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/provisioners/chef/installer.rb
vagrant-unbundled-1.8.5.2 plugins/provisioners/chef/installer.rb
vagrant-unbundled-1.8.5.1 plugins/provisioners/chef/installer.rb
vagrant-unbundled-1.8.4.2 plugins/provisioners/chef/installer.rb
vagrant-unbundled-1.8.4.1 plugins/provisioners/chef/installer.rb