Reputation: 35
I have created a new CentOS Linux release 7.2.1511 (Core) box by VirtualBox and Vagrant also I have followed the proper steps to create it
"Vagrant up" and "vagrant ssh" commands are working properly but when I try to "vagrant halt" I got the following error:
The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!
shutdown -h now
Stdout from the command:
Stderr from the command:
sudo: no tty present and no askpass program specified
When I go in to the box by "vagrant ssh" command and run the "shutdown -h now" command I have been asked for the vagrant user password:
[hww_vagrant@centos7x64 ~]$ shutdown -h now ==== AUTHENTICATING FOR org.freedesktop.login1.power-off === Authentication is required for powering off the system. Authenticating as: hww_vagrant Password:
It shouldn't ask me as I have add the following row on sudoers file:
hww_vagrant ALL=(ALL) NOPASSWD: ALL
, and also I have commented the following row on sudoers file too:
Defaults requiretty
Here is the problem....as I have been asked for password when vagrant user tries to power off the box when I try to run "vagrant halt" it fails.
I think it should works with my configuration but still asking me the password for powering off the box by "vagrant" user...Does anybody what is happening?
Thanks!
Upvotes: 1
Views: 586
Reputation: 35
Finally, the configuration was ok. My vagrant user belong to wheel group and it was causing the error.
I have removed my vagrant_user from wheel group and it worked:
usermod -G "" user_vagrant
Thanks.
Upvotes: 0
Reputation: 53753
based on this post the following should work
create a file /etc/polkit-1/rules.d/00-stop-reboot.rules
with the content
polkit.addRule(function(action, subject) {
if (action.id.indexOf("org.freedesktop.login1.hibernate") == 0) {
return polkit.Result.AUTH_ADMIN;
}
});
polkit.addRule(function(action, subject) {
if (action.id.indexOf("org.freedesktop.login1.power-off") == 0) {
return polkit.Result.AUTH_ADMIN;
}
});
polkit.addRule(function(action, subject) {
if (action.id.indexOf("org.freedesktop.login1.reboot") == 0) {
return polkit.Result.AUTH_ADMIN;
}
});
polkit.addRule(function(action, subject) {
if (action.id.indexOf("org.freedesktop.login1.suspend") == 0) {
return polkit.Result.AUTH_ADMIN;
}
});
You will have to add that in packer (if thats what you use for box creation) or just before you package the box so this will be available when you run vagrant halt
command
Upvotes: 1