Sha256: ed604bdf5a52f9772a5864b4efc0c52addea4bf05b91a31f46e10a95d3c0ae5d

Contents?: true

Size: 770 Bytes

Versions: 7

Compression:

Stored size: 770 Bytes

Contents

require "log4r"

module Vagrant
  module Action
    module Builtin
      # This middleware sets the hostname of the guest according to the
      # "vm.hostname" configuration parameter if it is set. This middleware
      # should be placed such that the after the @app.call, a booted machine
      # is available (this generally means BEFORE the boot middleware).
      class SetHostname
        def initialize(app, env)
          @app = app
        end

        def call(env)
          @app.call(env)

          hostname = env[:machine].config.vm.hostname
          if !hostname.nil?
            env[:ui].info I18n.t("vagrant.actions.vm.hostname.setting")
            env[:machine].guest.change_host_name(hostname)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
vagrantup-1.1.3 lib/vagrant/action/builtin/set_hostname.rb
vagrantup-1.1.2 lib/vagrant/action/builtin/set_hostname.rb
vagrantup-1.1.1 lib/vagrant/action/builtin/set_hostname.rb
vagrantup-1.1.0 lib/vagrant/action/builtin/set_hostname.rb
vagrantup-1.1.4 lib/vagrant/action/builtin/set_hostname.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/lib/vagrant/action/builtin/set_hostname.rb
vagrant-lxc-0.0.1 vendor/vagrant/lib/vagrant/action/builtin/set_hostname.rb