所以,我有一个带代码的Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
config.vm.provision "shell", inline: 'echo "Read line:" && read t && echo "$t"'
...
end
当我执行vagrant provision
时,我有输出:
$ vagrant provision
...
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Read line:
==> default: exit
没有建议从keyboard / stdin输入一行!
在配置shell脚本执行期间,我应该怎么做才能从keyboard / stdin读取行?
答案 0 :(得分:2)
我这样做,在我的Vagrantfile
中puts "Input text: "
input = STDIN.gets.chomp
config.vm.provision :shell, inline: "echo #{input}"