vagrant provision:从键盘/ stdin读取行

时间:2016-04-29 07:55:06

标签: vagrant vagrantfile vagrant-provision

所以,我有一个带代码的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读取行?

1 个答案:

答案 0 :(得分:2)

我这样做,在我的Vagrantfile

puts "Input text: "
input = STDIN.gets.chomp

config.vm.provision :shell, inline: "echo #{input}"