Class: VagrantPlugins::Conductor::Provisioner

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/conductor/provisioner.rb

Overview

This class implements provisioning via conductor modules.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Provisioner

Initialize the provisioner



13
14
15
16
17
18
# File 'lib/vagrant/conductor/provisioner.rb', line 13

def initialize(config)
  @config = config
  @path = File.expand_path('modules', __dir__)
  @sync_path = sync_folder
  @initialized = Hash.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/vagrant/conductor/provisioner.rb', line 7

def config
  @config
end

#initializedObject (readonly)

Returns the value of attribute initialized.



10
11
12
# File 'lib/vagrant/conductor/provisioner.rb', line 10

def initialized
  @initialized
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/vagrant/conductor/provisioner.rb', line 8

def path
  @path
end

#sync_pathObject (readonly)

Returns the value of attribute sync_path.



9
10
11
# File 'lib/vagrant/conductor/provisioner.rb', line 9

def sync_path
  @sync_path
end

Instance Method Details

#available_modules(path) ⇒ Object

Get a list of the available modules



42
43
44
# File 'lib/vagrant/conductor/provisioner.rb', line 42

def available_modules(path)
  Dir.glob(path + '/*').select { |f| File.directory? f }
end

#provision(args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vagrant/conductor/provisioner.rb', line 20

def provision(args)
  modules = VagrantPlugins::Conductor::Modules.new(available_modules(@path), args, @config, @sync_path)
  @initialized = modules.init

  if ENV.has_key?('MODULE') && @initialized.has_key?(ENV['MODULE'])
    @initialized[ENV['MODULE']].provision
  else
    @initialized.each do |name, object|
      object.provision
    end
  end

end

#sync_folderObject

set the sync folder



35
36
37
38
39
# File 'lib/vagrant/conductor/provisioner.rb', line 35

def sync_folder
  sync_path = '/tmp/conductor/modules'
  @config.vm.synced_folder @path, sync_path
  sync_path
end