Class: Vagrant::Action::Builtin::SetHostname
- Inherits:
-
Object
- Object
- Vagrant::Action::Builtin::SetHostname
- Defined in:
- lib/vagrant/action/builtin/set_hostname.rb
Overview
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).
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ SetHostname
constructor
A new instance of SetHostname.
Constructor Details
#initialize(app, env) ⇒ SetHostname
Returns a new instance of SetHostname.
11 12 13 |
# File 'lib/vagrant/action/builtin/set_hostname.rb', line 11 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant/action/builtin/set_hostname.rb', line 15 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 |