Class: Vagrant::Provisioners::Base

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/vagrant/provisioners/base.rb

Overview

The base class for a "provisioner." A provisioner is responsible for provisioning a Vagrant system. This has been abstracted out to provide support for multiple solutions such as Chef Solo, Chef Client, and Puppet.

Direct Known Subclasses

Chef, Puppet, PuppetServer, Shell

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, config) ⇒ Base

Returns a new instance of Base.



31
32
33
34
# File 'lib/vagrant/provisioners/base.rb', line 31

def initialize(env, config)
  @action_env = env
  @config = config
end

Instance Attribute Details

#action_envObject (readonly)

The environment which provisioner is running in. This is a Action::Environment



12
13
14
# File 'lib/vagrant/provisioners/base.rb', line 12

def action_env
  @action_env
end

#configObject (readonly)

The configuration for this provisioner. This will be an instance of the Config class which is part of the provisioner.



16
17
18
# File 'lib/vagrant/provisioners/base.rb', line 16

def config
  @config
end

Class Method Details

.register(shortcut) ⇒ Object

Registers a provisioner with a given shortcut. This allows that provisioner to be referenced with the shortcut.

Parameters:

  • shortcut (Symbol)


22
23
24
# File 'lib/vagrant/provisioners/base.rb', line 22

def self.register(shortcut)
  registered[shortcut] = self
end

.registeredObject

Returns the provisioner associated with the given shortcut.



27
28
29
# File 'lib/vagrant/provisioners/base.rb', line 27

def self.registered
  @@registered ||= {}
end

Instance Method Details

#envVagrant::Environment

Returns the actual Environment which this provisioner represents.



40
41
42
# File 'lib/vagrant/provisioners/base.rb', line 40

def env
  action_env.env
end

#prepareObject

This is the method called to "prepare" the provisioner. This is called before any actions are run by the action runner (see Actions::Runner). This can be used to setup shared folders, forward ports, etc. Whatever is necessary on a "meta" level.



55
# File 'lib/vagrant/provisioners/base.rb', line 55

def prepare; end

#provision!Object

This is the method called to provision the system. This method is expected to do whatever necessary to provision the system (create files, SSH, etc.)



60
# File 'lib/vagrant/provisioners/base.rb', line 60

def provision!; end

#vmVagrant::VM

Returns the VM which this provisioner is working on.

Returns:



47
48
49
# File 'lib/vagrant/provisioners/base.rb', line 47

def vm
  env.vm
end