Sha256: b8466737cbde934b8f05c28ac2ca445811dd1071c7ad3947f1e82455de59d73f

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

module Vagrant
  class Action
    module VM
      # Puts a generated Vagrantfile into the package directory so that
      # it can be included in the package.
      class PackageVagrantfile
        include Util

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

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

        # 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.
        def create_vagrantfile
          File.open(File.join(@env["package.directory"], "Vagrantfile"), "w") do |f|
            f.write(TemplateRenderer.render("package_Vagrantfile", {
              :base_mac => @env["vm"].vm.network_adapters.first.mac_address
            }))
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
vagrantup-0.5.1 lib/vagrant/action/vm/package_vagrantfile.rb
vagrant-0.5.1 lib/vagrant/action/vm/package_vagrantfile.rb