Increase memory of a particular vagrant box
Asked Answered
N

1

5

I have this Vagrantfile. Here I defined the memory to be 2048 for all VMs. But I want my puppet master to have 4096 and agents to have 2048. How to do that?

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

Thanks!

Newel answered 16/5, 2017 at 10:37 Comment(0)
O
9

You can easily do that by overriding the value for a specific 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

so your whole file becomes

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
Overseas answered 16/5, 2017 at 10:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.