Answering prompt using vagrant file?

2019-04-19 02:06发布

Is it possible to add a script to a Vagrantfile that answers a prompt. I am provisioning a ubuntu box for docker

config.vm.box = "ubuntu"

config.vm.provision :shell, :inline => "sudo apt-get update"

config.vm.provision :shell, :inline => "sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring"

After running the last command, there is a prompt that asks

Do you want to continue [Y/n]?

1条回答
啃猪蹄的小仙女
2楼-- · 2019-04-19 02:39

An easier solution would be to use the -y option of apt-get:

config.vm.provision :shell, :inline => "sudo apt-get -y install linux-image-generic-lts-raring linux-headers-generic-lts-raring"

See the manual:

-y, --yes, --assume-yes Automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package or removing an essential package, occurs then apt-get will abort.

查看更多
登录 后发表回答