gpt4 book ai didi

vagrant - 增加特定 vagrant box 的内存

转载 作者:行者123 更新时间:2023-12-03 20:32:12 24 4
gpt4 key购买 nike

我有这个 Vagrantfile。在这里,我将所有 VM 的内存定义为 2048。但是我希望我的傀儡师有 4096,代理有 2048。怎么做?

Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end

config.vm.define "puppetmaster" do |pm|
pm.vm.box = "centos/7"
pm.vm.network "private_network", ip: "192.168.33.10"
pm.vm.hostname = "puppetmaster"
end

config.vm.define "puppet-agent-centos" do |pac|
pac.vm.box = "centos/7"
pac.vm.network "private_network", ip: "192.168.33.11"
pac.vm.hostname = "centos-agent"
end

config.vm.define "puppet-agent-ubuntu" do |pau|
pau.vm.box = "ubuntu/xenial64"
pau.vm.network "private_network", ip: "192.168.33.12"
pau.vm.hostname = "ubuntu-agent"
end
end

谢谢!

最佳答案

您可以通过覆盖特定 VM 的值轻松做到这一点

  config.vm.define "puppetmaster" do |pm|
pm.vm.box = "centos/7"
pm.vm.network "private_network", ip: "192.168.33.10"
pm.vm.hostname = "puppetmaster"

pm.vm.provider "virtualbox" do |pmv|
pmv.memory = 4096
end
end

所以你的整个文件变成
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end

config.vm.define "puppetmaster" do |pm|
pm.vm.box = "centos/7"
pm.vm.network "private_network", ip: "192.168.33.10"
pm.vm.hostname = "puppetmaster"

pm.vm.provider "virtualbox" do |pmv|
pmv.memory = 4096
end
end

config.vm.define "puppet-agent-centos" do |pac|
pac.vm.box = "centos/7"
pac.vm.network "private_network", ip: "192.168.33.11"
pac.vm.hostname = "centos-agent"
end

config.vm.define "puppet-agent-ubuntu" do |pau|
pau.vm.box = "ubuntu/xenial64"
pau.vm.network "private_network", ip: "192.168.33.12"
pau.vm.hostname = "ubuntu-agent"
end
end

关于vagrant - 增加特定 vagrant box 的内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43999126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com