hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.26k stars 4.43k forks source link

config.vm.hostname for Ubuntu 15.04 fails #5673

Closed jameskyle closed 9 years ago

jameskyle commented 9 years ago

Error below. The hostname service is masked in ubuntu 15.04, the recommended way to control the hostname seems to be hostnamectl.

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

service hostname start

Stdout from the command:

Stderr from the command:

sudo: unable to resolve host ubuntu-1504
stdin: is not a tty
Failed to start hostname.service: Unit hostname.service is masked.
ev0rtex commented 9 years ago

I'm having the same issue. I just tried with 15.04 today and got this.

matthiss commented 9 years ago

I've tried

sudo systemctl unmask hostname.service

it seems everything ok, no errors, but if i want to start the service, it is still masked.

Any ideas?

jklare commented 9 years ago

having the same issue

devjatkin commented 9 years ago

I got the same error message. On my Ubuntu VM ( based on image from cloud.ubuntu) I saw the next:

sudo systemctl status hostname
● hostname.service
   Loaded: masked (/dev/null)
   Active: inactive (dead)
ls -la /lib/systemd/system/hostname.service 
lrwxrwxrwx 1 root root 9 Apr 18 21:11 /lib/systemd/system/hostname.service -> /dev/null

As temporary workaround it is possible to use /etc/init.d/hostname.sh

nserban commented 9 years ago

I encounter the same problem reported by @jameskyle but on a Debian Wheezy, after an apt-get update ; apt-get upgrade .

root@local:~# uname -a
Linux local 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linu

I retested with a upgraded Debian box 7.8, the creation of the VM is working fine, but after a vagrant halt and vagrant up with this line in Vagrantfile

config.vm.hostname = "local.supercool.com"

I encounter the same problem.

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

hostname -f

Stdout from the command:

Stderr from the command:

sudo: unable to resolve host local
stdin: is not a tty
hostname: Name or service not known

Here are the Vagrant Log:

/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
 INFO interface: error: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

hostname -f

Stdout from the command:

Stderr from the command:

sudo: unable to resolve host local
stdin: is not a tty
hostname: Name or service not known

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

hostname -f

Stdout from the command:

Stderr from the command:

sudo: unable to resolve host local
stdin: is not a tty
hostname: Name or service not known

 INFO interface: Machine: error-exit ["Vagrant::Errors::VagrantError", "The following SSH command responded with a non-zero exit status.\nVagrant assumes that this means the command failed!\n\nhostname -f\n\nStdout from the command:\n\n\n\nStderr from the command:\n\nsudo: unable to resolve host local\nstdin: is not a tty\nhostname: Name or service not known\n"]
eckz commented 9 years ago

It seems like the only work-around for now is

#host.vm.hostname = "skynet"
host.vm.provision :shell, inline: "hostnamectl set-hostname skynet"
thasmo commented 9 years ago

Encountering the same on Ubuntu 15.04.

born4new commented 9 years ago

Same here. Can't wait to see the fix!

majidaldo commented 9 years ago

yup

czerasz commented 9 years ago

After updating to Vagrant 1.7.4 everything works fine. Tested with ubuntu/vivid64

dylanraithel commented 9 years ago

@czerasz version upgrade to Vagrant 1.7.4 fixed the issue for me as well with ubuntu/vivid64

jgoldschrafe commented 9 years ago

This is breaking again on the Wily betas. Can we have a better fix that doesn't rely on checking the codename of one specific release?

markwoon commented 8 years ago

Still broken with ubuntu/wily and vagrant 1.7.4...

luebken commented 8 years ago

Still broken with ubuntu/wily and vagrant 1.7.4...

+1

I saw it fixed for vivid but came up again for wily.

rogerhu commented 8 years ago

PR'd https://github.com/mitchellh/vagrant/pull/6470 -> avoids hard-coding Ubuntu distribution names

rogerhu commented 8 years ago

Closed and reopened: https://github.com/mitchellh/vagrant/pull/6471

nubae commented 8 years ago

Problem is also there in 16.04 (fix #6470 does not work): root@ns399965:/tmp/ispconfig3/install# hostnamectl set-hostname ns1 root@ns399965:/tmp/ispconfig3/install# sudo systemctl status hostname ● hostname.service Loaded: masked (/dev/null; bad) Active: inactive (dead) root@ns399965:/tmp/ispconfig3/install#

nubae commented 8 years ago

workaround: root@ns399965:/tmp/ispconfig3/install# sh /etc/init.d/hostname.sh root@ns399965:/tmp/ispconfig3/install# hostname -f ns1.soulternative.eu

reedloden commented 8 years ago

@nubae can you file a new issue, please?

reedloden commented 8 years ago

@nubae actually, https://github.com/mitchellh/vagrant/issues/7288 is this, no?

nubae commented 8 years ago

@reedloden yup that seems to be the same issue... still need to re-file a new issue or not?

ravishtiwari commented 7 years ago

Using Vagrant 1.7.4 with Ubunut 16.04 and still having the issue:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

service hostname start

Stdout from the command:

Stderr from the command:

sudo: unable to resolve host ubuntu-xenial: Connection timed out
mesg: ttyname failed: Inappropriate ioctl for device
Failed to start hostname.service: Unit hostname.service is masked.

Ubuntu Box Version: '20161214.0.0'

awibmer commented 7 years ago

@ravishtiwari Upgrading to Vagrant 1.9.1 solved this for me.

ravishtiwari commented 7 years ago

@awibmer - I've recently upgraded to Vagrant 1.9.1 will confirm if the issue is fixed for me as well.

Thanks

jeunito commented 7 years ago

Upgrading to 1.8.5 solved this for me

ravishtiwari commented 7 years ago

@awibmer - upgrading to 1.9.1 has resolved this for me as well, thanks for your help.

daBONDi commented 5 years ago

Im now on vagrant 2.2.1 and have the same problem now

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.