Sha256: 562cb15432b28dbd5929634607cc8e282daabd76ae3393b89a40c4572579c559

Contents?: true

Size: 1.67 KB

Versions: 46

Compression:

Stored size: 1.67 KB

Contents

module Vagrant
  module Action
    module Builtin
      module MixinProvisioners
        # This returns all the instances of the configured provisioners.
        # This is safe to call multiple times since it will cache the results.
        #
        # @return [Array<Provisioner, Hash>]
        def provisioner_instances(env)
          return @_provisioner_instances if @_provisioner_instances

          # Make the mapping that'll keep track of provisioner => type
          @_provisioner_types = {}

          # Get all the configured provisioners
          @_provisioner_instances = env[:machine].config.vm.provisioners.map do |provisioner|
            # Instantiate the provisioner
            klass  = Vagrant.plugin("2").manager.provisioners[provisioner.type]

            # This can happen in the case the configuration isn't validated.
            next nil if !klass

            result = klass.new(env[:machine], provisioner.config)

            # Store in the type map so that --provision-with works properly
            @_provisioner_types[result] = provisioner.type

            # Build up the options
            options = {
              name: provisioner.name,
              run:  provisioner.run,
            }

            # Return the result
            [result, options]
          end

          return @_provisioner_instances.compact
        end

        # This will return a mapping of a provisioner instance to its
        # type.
        def provisioner_type_map(env)
          # Call this in order to initial the map if it hasn't been already
          provisioner_instances(env)

          # Return the type map
          @_provisioner_types
        end
      end
    end
  end
end

Version data entries

46 entries across 39 versions & 6 rubygems

Version Path
vagrant-unbundled-2.2.5.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.2.4.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.2.3.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.2.2.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.2.0.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.1.4.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.1.2.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.1.1.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.0.4.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.0.3.0 lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/lib/vagrant/action/builtin/mixin_provisioners.rb
vagrant-unbundled-2.0.2.0 lib/vagrant/action/builtin/mixin_provisioners.rb