Class: Vagrant::Action::VM::PackageVagrantfile

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/vagrant/action/vm/package_vagrantfile.rb

Overview

Puts a generated Vagrantfile into the package directory so that it can be included in the package.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PackageVagrantfile

Returns a new instance of PackageVagrantfile.



12
13
14
15
# File 'lib/vagrant/action/vm/package_vagrantfile.rb', line 12

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
# File 'lib/vagrant/action/vm/package_vagrantfile.rb', line 17

def call(env)
  @env = env
  create_vagrantfile
  @app.call(env)
end

#create_vagrantfileObject

This method creates the auto-generated Vagrantfile at the root of the box. This Vagrantfile contains the MAC address so that the user doesn't have to worry about it.



26
27
28
29
30
31
32
# File 'lib/vagrant/action/vm/package_vagrantfile.rb', line 26

def create_vagrantfile
  File.open(File.join(@env["export.temp_dir"], "Vagrantfile"), "w") do |f|
    f.write(TemplateRenderer.render("package_Vagrantfile", {
      :base_mac => @env["vm"].driver.read_mac_address
    }))
  end
end