配置具有继承、覆盖内存的多个主机
Configure multiple hosts with inheritance, overriding memory
我有一个 Vagrantfile
配置了 6 个虚拟机。除了必要的内存大小(和 ip 地址)外,它们都很相似。
我想为 RAM 大小设置默认值并在必要时更改它,process1
和 process2
应该得到 6GB。
我尝试使用几个前缀(app、v、...)更改 .memory
,但显然语法不正确。
我也试过 app.customize ["modifyvm", :id, "--memory", "6144"]
但 vagrant validate
抱怨这个。
目前文件如下所示:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure( VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "geerlingguy/centos7"
config.vm.provider :virtualbox do |v|
v.memory = 2048
v.linked_clone = true
end
config.vm.define "process1" do |app|
app.vm.hostname = "process1"
app.vm.network :private_network, ip: "192.168.60.11"
end
config.vm.define "process2" do |app|
app.vm.hostname = "process2"
app.vm.network :private_network, ip: "192.168.60.12"
end
config.vm.define "index1" do |app|
app.vm.hostname = "index1"
app.vm.network :private_network, ip: "192.168.60.13"
end
config.vm.define "index2" do |app|
app.vm.hostname = "index2"
app.vm.network :private_network, ip: "192.168.60.14"
end
config.vm.define "quorum" do |app|
app.vm.hostname = "quorum"
app.vm.network :private_network, ip: "192.168.60.15"
end
config.vm.define "control" do |app|
app.vm.hostname = "control"
app.vm.network :private_network, ip: "192.168.60.21"
end
end
您需要覆盖每个块
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure( VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "geerlingguy/centos7"
config.vm.provider :virtualbox do |v|
v.memory = 2048
v.linked_clone = true
end
config.vm.define "process1" do |app|
app.vm.hostname = "process1"
app.vm.network :private_network, ip: "192.168.60.11"
app.vm.provider :virtualbox do |v|
v.memory = 6144
end
end
config.vm.define "process2" do |app|
app.vm.hostname = "process2"
app.vm.network :private_network, ip: "192.168.60.12"
app.vm.provider :virtualbox do |v|
v.memory = 6144
end
end
config.vm.define "index1" do |app|
app.vm.hostname = "index1"
app.vm.network :private_network, ip: "192.168.60.13"
end
config.vm.define "index2" do |app|
app.vm.hostname = "index2"
app.vm.network :private_network, ip: "192.168.60.14"
end
config.vm.define "quorum" do |app|
app.vm.hostname = "quorum"
app.vm.network :private_network, ip: "192.168.60.15"
end
config.vm.define "control" do |app|
app.vm.hostname = "control"
app.vm.network :private_network, ip: "192.168.60.21"
end
end
我有一个 Vagrantfile
配置了 6 个虚拟机。除了必要的内存大小(和 ip 地址)外,它们都很相似。
我想为 RAM 大小设置默认值并在必要时更改它,process1
和 process2
应该得到 6GB。
我尝试使用几个前缀(app、v、...)更改 .memory
,但显然语法不正确。
我也试过 app.customize ["modifyvm", :id, "--memory", "6144"]
但 vagrant validate
抱怨这个。
目前文件如下所示:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure( VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "geerlingguy/centos7"
config.vm.provider :virtualbox do |v|
v.memory = 2048
v.linked_clone = true
end
config.vm.define "process1" do |app|
app.vm.hostname = "process1"
app.vm.network :private_network, ip: "192.168.60.11"
end
config.vm.define "process2" do |app|
app.vm.hostname = "process2"
app.vm.network :private_network, ip: "192.168.60.12"
end
config.vm.define "index1" do |app|
app.vm.hostname = "index1"
app.vm.network :private_network, ip: "192.168.60.13"
end
config.vm.define "index2" do |app|
app.vm.hostname = "index2"
app.vm.network :private_network, ip: "192.168.60.14"
end
config.vm.define "quorum" do |app|
app.vm.hostname = "quorum"
app.vm.network :private_network, ip: "192.168.60.15"
end
config.vm.define "control" do |app|
app.vm.hostname = "control"
app.vm.network :private_network, ip: "192.168.60.21"
end
end
您需要覆盖每个块
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure( VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "geerlingguy/centos7"
config.vm.provider :virtualbox do |v|
v.memory = 2048
v.linked_clone = true
end
config.vm.define "process1" do |app|
app.vm.hostname = "process1"
app.vm.network :private_network, ip: "192.168.60.11"
app.vm.provider :virtualbox do |v|
v.memory = 6144
end
end
config.vm.define "process2" do |app|
app.vm.hostname = "process2"
app.vm.network :private_network, ip: "192.168.60.12"
app.vm.provider :virtualbox do |v|
v.memory = 6144
end
end
config.vm.define "index1" do |app|
app.vm.hostname = "index1"
app.vm.network :private_network, ip: "192.168.60.13"
end
config.vm.define "index2" do |app|
app.vm.hostname = "index2"
app.vm.network :private_network, ip: "192.168.60.14"
end
config.vm.define "quorum" do |app|
app.vm.hostname = "quorum"
app.vm.network :private_network, ip: "192.168.60.15"
end
config.vm.define "control" do |app|
app.vm.hostname = "control"
app.vm.network :private_network, ip: "192.168.60.21"
end
end