Vagrant 自动化用户输入
Vagrant automate user input
我正在使用多机设置并启动 5 台机器,当我键入 vagrant up
我希望输入为默认值 1 当我被问及它时(我不想要继续输入 1 五次)
Preview of Input options upon typing vagrant up command
这是 vagrant 文件
IMAGE_NAME = "ubuntu/bionic64"
N = 2
Vagrant.configure("2") do |config|
config.vm.box_check_update = false
# Master Nodes
(1..N).each do |i|
config.vm.define "master-#{i}" do |master|
master.vm.box = IMAGE_NAME
master.vm.hostname = "master-#{i}"
master.vm.network "public_network", ip: "192.168.5.#{i + 10}"
master.vm.network "private_network", ip: "192.168.11.#{i + 10}"
end
end
# Worker Nodes
(1..N).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.box = IMAGE_NAME
node.vm.hostname = "node-#{i}"
node.vm.network "public_network", ip: "192.168.6.#{i + 10}"
node.vm.network "private_network", ip: "192.168.12.#{i + 10}"
end
end
# Load Balancer
config.vm.define "load-balancer" do |lb|
lb.vm.box = IMAGE_NAME
lb.vm.hostname = "load-balancer"
lb.vm.network "public_network", ip: "192.168.7.11"
lb.vm.network "private_network", ip: "192.168.13.11"
end
end
在你的 Vagrantfile 中,你应该在你使用的地方添加 public_network
你需要指定网络适配器
<machine>.vm.network "public_network", ip: xxx, bridge: "nat"
我正在使用多机设置并启动 5 台机器,当我键入 vagrant up
我希望输入为默认值 1 当我被问及它时(我不想要继续输入 1 五次)
Preview of Input options upon typing vagrant up command
这是 vagrant 文件
IMAGE_NAME = "ubuntu/bionic64"
N = 2
Vagrant.configure("2") do |config|
config.vm.box_check_update = false
# Master Nodes
(1..N).each do |i|
config.vm.define "master-#{i}" do |master|
master.vm.box = IMAGE_NAME
master.vm.hostname = "master-#{i}"
master.vm.network "public_network", ip: "192.168.5.#{i + 10}"
master.vm.network "private_network", ip: "192.168.11.#{i + 10}"
end
end
# Worker Nodes
(1..N).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.box = IMAGE_NAME
node.vm.hostname = "node-#{i}"
node.vm.network "public_network", ip: "192.168.6.#{i + 10}"
node.vm.network "private_network", ip: "192.168.12.#{i + 10}"
end
end
# Load Balancer
config.vm.define "load-balancer" do |lb|
lb.vm.box = IMAGE_NAME
lb.vm.hostname = "load-balancer"
lb.vm.network "public_network", ip: "192.168.7.11"
lb.vm.network "private_network", ip: "192.168.13.11"
end
end
在你的 Vagrantfile 中,你应该在你使用的地方添加 public_network
你需要指定网络适配器
<machine>.vm.network "public_network", ip: xxx, bridge: "nat"