Thursday, August 28, 2014

Windows Pagefile Cookbook - Update #getchef

After some usage I noticed some inconsistencies with the way I was grabbing and converting the Ram. I decided to move back to the case statement method even though I have to have 2 different settings based off who ohai sees the OSes and the different hypervisor platforms. YMMV

Here is the cookbook as it now stands on Github. Again YMMV.

default.rb

def memory
  "#{node['kernel']['cs_info']['total_physical_memory']}"
end


case memory
when "2147012608"
  include_recipe "pagefile::2gb"
when "4294496256"
  include_recipe "pagefile::4gb"
when "4290367488"
  include_recipe "pagefile::4gb"
when "6433652736"
  include_recipe "pagefile::6gb"
when "6441979904"
  include_recipe "pagefile::6gb"
when "8585334784"
  include_recipe "pagefile::8gb"
when "8589463552"
  include_recipe "pagefile::8gb"
when "17175269376"
  include_recipe "pagefile::16gb"
when "17171070976"
  include_recipe "pagefile::16gb"
end

2gb.rb

# Set pagefile
windows_pagefile 'c:\pagefile.sys' do
  initial_size (3072)
  maximum_size (3072)
  system_managed false
  automatic_managed false
  action :set
  not_if {reboot_pending?}
end

# if reboot needed
windows_reboot 30 do
  reason 'Chef said reboot'
  only_if {reboot_pending?}
end

4gb.rb

# Set pagefile
windows_pagefile 'c:\pagefile.sys' do
  initial_size (6144)
  maximum_size (6144)
  system_managed false
  automatic_managed false
  action :set
  not_if {reboot_pending?}
end

# if reboot needed
windows_reboot 30 do
  reason 'Chef said reboot'
  only_if {reboot_pending?}
end

6gb.rb

# Set pagefile
windows_pagefile 'c:\pagefile.sys' do
  initial_size (9216)
  maximum_size (9216)
  system_managed false
  automatic_managed false
  action :set
  not_if {reboot_pending?}
end

# if reboot needed
windows_reboot 30 do
  reason 'Chef said reboot'
  only_if {reboot_pending?}
end

8gb.rb

# Set pagefile
windows_pagefile 'c:\pagefile.sys' do
  initial_size (8193)
  maximum_size (8193)
  system_managed false
  automatic_managed false
  action :set
  not_if {reboot_pending?}
end

# if reboot needed
windows_reboot 30 do
  reason 'Chef said reboot'
  only_if {reboot_pending?}
end

16gb.rb

# Set pagefile
windows_pagefile 'c:\pagefile.sys' do
  initial_size (16385)
  maximum_size (16385)
  system_managed false
  automatic_managed false
  action :set
  not_if {reboot_pending?}
end

# if reboot needed
windows_reboot 30 do
  reason 'Chef said reboot'
  only_if {reboot_pending?}
end

No comments:

Post a Comment