vagrant provision: read line from keyboard/stdin

2019-09-06 01:58发布

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条回答
劳资没心,怎么记你
2楼-- · 2019-09-06 02:34

I do it this way, in my Vagrantfile

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

config.vm.provision :shell, inline: "echo #{input}"
查看更多
登录 后发表回答