diff --git a/CHANGELOG.md b/CHANGELOG.md index 262d41390..2c819c479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ IMPROVEMENTS: + - Setting hostnames works properly on SmartOS. [GH-1672] - Better VBoxManage error detection on Windows systems. This avoids some major issues where Vagrant would sometimes "lose" your VM. [GH-1669] - Better detection of missing VirtualBox kernel drivers on Linux diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 6bb8a4286..632dcf9a5 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -193,6 +193,8 @@ module Vagrant # # @param [String] value The ID. def id=(value) + @logger.info("New machine ID: #{value.inspect}") + # The file that will store the id if we have one. This allows the # ID to persist across Vagrant runs. id_file = @data_dir.join("id") diff --git a/plugins/guests/smartos/cap/change_host_name.rb b/plugins/guests/smartos/cap/change_host_name.rb new file mode 100644 index 000000000..f839cf467 --- /dev/null +++ b/plugins/guests/smartos/cap/change_host_name.rb @@ -0,0 +1,17 @@ +module VagrantPlugins + module GuestSmartOS + module Cap + class ChangeHostName + def self.change_host_name(machine, name) + su_cmd = machine.config.solaris.suexec_cmd + + # Only do this if the hostname is not already set + if !machine.communicate.test("#{su_cmd} hostname | grep '#{name}'") + machine.communicate.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"") + machine.communicate.execute("#{su_cmd} hostname #{name}") + end + end + end + end + end +end diff --git a/plugins/guests/smartos/guest.rb b/plugins/guests/smartos/guest.rb new file mode 100644 index 000000000..d72b68186 --- /dev/null +++ b/plugins/guests/smartos/guest.rb @@ -0,0 +1,11 @@ +require "vagrant" + +module VagrantPlugins + module GuestSmartOS + class Guest < Vagrant.plugin("2", :guest) + def detect?(machine) + machine.communicate.test("cat /etc/release | grep -i SmartOS") + end + end + end +end diff --git a/plugins/guests/smartos/plugin.rb b/plugins/guests/smartos/plugin.rb new file mode 100644 index 000000000..e8f84bb39 --- /dev/null +++ b/plugins/guests/smartos/plugin.rb @@ -0,0 +1,20 @@ +require "vagrant" + +module VagrantPlugins + module GuestSmartOS + class Plugin < Vagrant.plugin("2") + name "SmartOS guest." + description "SmartOS guest support." + + guest("smartos", "solaris") do + require File.expand_path("../guest", __FILE__) + Guest + end + + guest_capability("smartos", "change_host_name") do + require_relative "cap/change_host_name" + Cap::ChangeHostName + end + end + end +end