vagrant 1.8.1
Ubuntu 16.04
Ubuntu 16.04 (boxcutter/ubuntu1604)
After doing some digging on this message that I had been seeing:
==> server1: Machine booted and ready!
==> server1: Checking for guest additions in VM...
==> server1: Setting hostname...
==> server1: Running provisioner: shell...
server1: Running: inline script
==> server1: mesg:
==> server1: ttyname failed
==> server1: :
==> server1: Inappropriate ioctl for device
I determined it had a similar cause as mitchellh/vagrant#1673 and a similar potential fix. I've started adding this line to my Vagrantfiles. There may be security ramifications for this fix as it essentially removes a built-in protection and allows other users to write to a root terminal but that is not a concern for my simulations /w Vagrant.
# Fixes "stdin: is not a tty" and "mesg: ttyname failed : Inappropriate ioctl for device" messages --> mitchellh/vagrant#1673
device.vm.provision :shell , inline: "(grep -q 'mesg n' /root/.profile && sed -i '/mesg n/d' /root/.profile && echo 'Ignore the previous error, fixing this now...') || exit 0;"
Not really a fix as such but if you're echoing anything out of your provisioner script I found you don't get the error above ^
I experienced this too. However, my host is MAC OS 10.11.6.
I get the same error message with bento/ubuntu-16.04 and vagrant 1.8.7 only after network is fully setup when running some custom shell provisioners.
==> db: Machine booted and ready!
==> db: Checking for guest additions in VM...
==> db: Setting hostname...
==> db: Configuring and enabling network interfaces...
==> db: Mounting shared folders...
db: /vagrant => D:/Dokumente/dev/mailserver/kath.de-playbooks
==> db: Running provisioner: shell...
db: Running: inline script
==> db: mesg:
==> db: ttyname failed
==> db: :
==> db: Inappropriate ioctl for device
==> db: Running provisioner: shell...
db: Running: inline script
==> db: mesg:
==> db: ttyname failed
==> db: :
==> db: Inappropriate ioctl for device
The provisioners are just some simple echos, nothing related to tty or anything special about devices:
config.vm.provision :shell, inline: "echo '#{ssh_keys}' >> /home/vagrant/.ssh/authorized_keys"
config.vm.provision :shell, inline: "echo '#{hosts}' >> /etc/hosts"
These inline commands do what they're supposed to, so the error seems to occur after the provisioner has finished.
Created a pull request https://github.com/mitchellh/vagrant/pull/8051 to resolve this issue.
While checking the capabilities of the linux guest, a call to /sbin/init is made using the command line parameter "--version". As not all versions of init know about this command line parameter, an error may be issued to stderr which is not "collected" by the following pipe. Thus it should be output to a tty, but there is none. This leads to the error message. Redirecting the stderr of the /sbin/init call to /dev/null resolves this issue.
Fixed via #8051
Hmm, I installed Vagrant 1.9.1 and I'm still seeing this error - it is preventing me from provisioning with Puppet on Ubuntu 16.04.
Looks like #8051 only fixes this message for mounts, not for inline shell provisioner
@chrisroberts Could you please reopen this issue as it is not yet fixed?
The "fix" for #8051 seems to be to suppress the error from showing up. It doesn't make sense to do so for inline scripts, or custom scripts invoked from vagrant.
Does anyone know why the error is displayed (by ubuntu)?
@shiva https://github.com/mitchellh/vagrant/issues/1673#issuecomment-28287711 is the best explanation I've found for why this is happening. For example, on bento/ubuntu-16.04:
vagrant@web:~$ sudo grep mesg /root/.profile
mesg n || true
(Note this means the grep -q -E '^mesg n$' /root/.profile part of a workaround script posted in some places won't quite match - the one above should work though)
@dominics That comment made me trust in humanity again ;)
As mentioned in the comments in that thread:
#1673 (comment-26650102) seems to be a better fix. However, it might not be a good idea to do that in vagrant. I think it would should be a choice to be made by the box creator (or Ubuntu). What do you think?
Most helpful comment
Looks like #8051 only fixes this message for mounts, not for inline shell provisioner