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.



9
10
11
12
# File 'lib/vagrant/action/vm/package_vagrantfile.rb', line 9

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

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
# File 'lib/vagrant/action/vm/package_vagrantfile.rb', line 14

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.



23
24
25
26
27
28
29
# File 'lib/vagrant/action/vm/package_vagrantfile.rb', line 23

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"].vm.network_adapters.first.mac_address
    }))
  end
end