问题
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