diff --git a/plugins/guests/ubuntu/guest.rb b/plugins/guests/ubuntu/guest.rb index 3999aef7e..76d768f41 100644 --- a/plugins/guests/ubuntu/guest.rb +++ b/plugins/guests/ubuntu/guest.rb @@ -10,15 +10,17 @@ module VagrantPlugins super # Emit an upstart event if upstart is available - vm.channel.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}") + vm.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}") end def change_host_name(name) - if !vm.channel.test("sudo hostname | grep '#{name}'") - vm.channel.sudo("sed -i 's/.*$/#{name}/' /etc/hostname") - vm.channel.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") - vm.channel.sudo("service hostname start") - vm.channel.sudo("hostname --fqdn > /etc/mailname") + vm.communicate.tap do |comm| + if !comm.test("sudo hostname | grep '#{name}'") + comm.sudo("sed -i 's/.*$/#{name}/' /etc/hostname") + comm.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") + comm.sudo("service hostname start") + comm.sudo("hostname --fqdn > /etc/mailname") + end end end end