Class: Vagrant::Vagrantfile

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/em/demos/Vagrantfile.rb

Instance Method Summary collapse

Constructor Details

#initialize(loader, keys) ⇒ Vagrantfile

Returns a new instance of Vagrantfile.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant/em/demos/Vagrantfile.rb', line 5

def initialize(loader, keys)
  @keys = keys
  @loader = loader
  @config, _ = loader.load(keys)
  @logger = Log4r::Logger.new("vagrant::vagrantfile")
  vagrant_root = Dir.pwd
  @config.ssh.insert_key = false
  config_reader = Vagrant::ConfigReader.new("#{vagrant_root}/#{@config.em.config_file}")
  @models = config_reader.read_configuration
  File.write("#{vagrant_root}/puppet_version", ENV["PUPPET_VERSION"]) if ENV["PUPPET_VERSION"]
  @models.each do |model|
    config.vm.define model.name do |vm|
      raise InvalidType if model.type.empty?

      @provisioners = []

      class_name = "Vagrant::EM::#{model.type.split("-").map(&:capitalize).join}"
      if Object.const_defined?(class_name)
        Object.const_get(class_name).setup(config, vm, model, @provisioners, @models)
      else
        raise "#{model.type} is invalid."
      end
      apply_provisioners(config, vm, model)
    end
  end
end