Reputation: 91
Local Host Environment: CentOS 7, Python 3.5.1, Fabric3 (1.11.1.post1)
Remote Host Environment: CentOS 7
fibfile:
def fuc():
reboot()
bash:
fab -f fibfile.py -H host -u root -p password
The remote host did reboot but returns a fatalError:
sudo() received nonzero return code -1 while executing 'reboot'!
Now I use warn_only
to prevent failure:
fabfile:
def test():
with settings(warn_only=True):
reboot()
Upvotes: 5
Views: 2921
Reputation: 350
You can put a shell session into the background which sleeps for 1 second then executes the reboot
command. Must be done without the use of nohup
command because of the nohup issue. I use tmux
...
reboot(command='tmux new-session -d "sleep 1; reboot;"')
Upvotes: 1
Reputation: 11544
I started having this problem with some new virtual machines. I think they do shut down too fast, as Jon Stark said.
To fix it, I ignore the error and the warning, like this.
with settings(hide('warnings'),
warn_only=True,
):
sudo("shutdown -r now")
Upvotes: 5
Reputation: 91
I find a similar question when use ansible: link
I think the top answer is right:
reboot
is shutting down the server so quickly that the server is tearing down the SSH connection.
shutdown -r now
return the same fatal error:
sudo() received nonzero return code -1 while executing 'shutdown -r now'!
shutdown -r +1
return success:
out: Shutdown scheduled for Mon 2016-05-23 14:16:48 UTC, use 'shutdown -c' to cancel.
But shutdown can only delay at least one minute. So we can only choose to wait for a minute or ignore the error.
Upvotes: 4