vagrant provision: read line from keyboard/stdin

狂风中的少年 提交于 2019-12-12 03:28:10

问题


And so, I have a Vagrantfile with code:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
  config.vm.provision "shell", inline: 'echo "Read line:" && read t && echo "$t"'
...
end

and when I execute vagrant provision i have that output:

$ vagrant provision
...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Read line:
==> default: exit

that is no suggest enter a line from keyboard/stdin!

What I should do for reading line from keyboard/stdin during provision shell script execution?


回答1:


I do it this way, in my Vagrantfile

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

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


来源:https://stackoverflow.com/questions/36932730/vagrant-provision-read-line-from-keyboard-stdin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!