Vagrant provision not working

2019-06-07 07:58发布

问题:

I have a problem with installing softwares using the vagrant provisions . I just tried to install git but I get this error :

==> default: stdin: is not a tty
==> default:   git-email git-gui gitk gitweb diffutils-doc
==> default: The following NEW packages will be installed:
==> default:   git git-man liberror-perl patch
==> default: 0 upgraded, 4 newly installed, 0 to remove and 179 not   upgraded.
==> default: Need to get 6,730 kB of archives.
==> default: After this operation, 15.4 MB of additional disk space will be used.
==> default: Do you want to continue [Y/n]?
==> default: Abort.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

my Vargantfile looks so :

Vagrant.configure(2) do |config|
 config.vm.box = "hashicorp/precise32"
 config.vm.provision "shell", path: "bootstrap.sh"
end

and my bootstrap.sh contains exactly :

#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install git

I tried it on mac and windows and get the same errors , I am using vagrant 1.7.2

回答1:

You need to add the -y flag when installing stuff from your bootstrap file, otherwise the system will wait for a confirmation

sudo apt-get -y install git


标签: vagrant