Sha256: b096fd4bcca9f70df804bfede062d561fa4fa451440832560bbc8113c2e365c0

Contents?: true

Size: 1.67 KB

Versions: 41

Compression:

Stored size: 1.67 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)
        @omnibus_url = options.fetch(:omnibus_url)
        @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, @omnibus_url, @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

41 entries across 37 versions & 5 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/provisioners/chef/installer.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.3.3.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.3.2.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.19.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.18.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.16.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.14.0 plugins/provisioners/chef/installer.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.10.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.9.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.8.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.7.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.6.2 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.6.1 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.6.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.5.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.4.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.3.0 plugins/provisioners/chef/installer.rb
vagrant-unbundled-2.2.2.0 plugins/provisioners/chef/installer.rb