Showing posts with label #DevOps. Show all posts
Showing posts with label #DevOps. Show all posts

Wednesday, October 8, 2014

#getchef running on #xenserver 6.2 - patching

I have been messing around with the idea that since XenServer 6.2 is based off Centos 5 , then I should be able to manage it with Chef. Even though there is a warning "this hasn't been regression tested" after installing the Chef-Client, it works pretty well.

Here are a couple of pics one installing some Hotfixes and another showing off the idempotence using a not_if from /var/patches/applied/. Both screen shots are from pool masters. I like it!







Friday, October 3, 2014

DevOpsCLE - MeetUp - Thoughts and impressions

MeetUp - DevOpsCLE

As my first MeetUp ever, I had the opportunity to present on DevOps and Windows. I posted the slide deck in a separate post last night so I won't include it again. The MeetUp was at LeanDog which is an awesome place that is actually a boat, I am not kidding. The atmosphere was very laid back and everyone was really welcoming.

As this was my first public presentation on how I am using Chef with Windows, besides evangelizing it at the office and a posting here, I feel that it went pretty well. We had 7-8 people in attendance, ranging from Linux developers, .Net programmers to Sysadmins(Linux/Windows). I did the basic presentation then proceeded to do a live demo with a Vagrant Windows 2012r2 server. I actually turned the server into a terminal server to show how Chef handles pending reboots. In the future, as a mental not to myself, increase the Ram on the VM....:)

To me the actual best part was the Q/A afterwards. We discussed the philosophy of what DevOps really is and how it can accelerate pretty much everything if everyone would just work together and understand the benefit to the business as a whole.

As an added benefit, I picked up some coding tips from some much better Rubyists than I...now time test and learn more. I really look forward to what is coming next...

You should check out the group and join us!

Friday, August 15, 2014

Challenges setting up a Chef Pagefile Cookbook

I figured this would be simple...I did it is Altiris without an issue. I have done it with reg files easily. How hard could it be? Well it was tricky. I wanted to leverage all the cool information that I got from ohai. So I started out like this using a Windows Server 2012R2 VM to grab the ohai results for the various settings.

Abandoned
default.rb

case node['kernel']['cs_info']['total_physical_memory']
when "2147012608"
  include_recipe "pagefile::2gb"
when "4294496256"
  include_recipe "pagefile::4gb"
when "6441979904"
  include_recipe "pagefile::6gb"
when "6437851136"
  include_recipe "pagefile::6gb"
when "8585334784"
  include_recipe "pagefile::8gb"
when "17171070976"
  include_recipe "pagefile::16gb"
end

Then I had corresponding jobs for - 2gb, 4gb, 6gb, 8gb, & 16gb

2gb.rb
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

Everything was going great. That was until I decided to set a VM that was on Windows Server 2008 R2. The recipe never ran.. So I proceeded to run ohai >c:\w2k8r28gb.txt. Sure enough, even though both VMs had the same 8GB installed, the total_physical_memory was different. So I proceeded to create additional when statements calling the same include_recipe. Ok so everything was running great on my VMs on CloudStack/XenServer.

I decided to test on vSphere and vCloud, guess what, all different...I couldn't believe it..

So I had to come up a completely different way. I tried making variables with ranges to no avail.

I ended up abandoning using ohai and the case in favor of some POSH and if, elsif, else.

Thanks to my buddy, Ron Oberjohann (ron@advdat.com) for help with the POSH. I was use 'Get-WMIObject -class Win32_PhysicalMemory', but wasn't doing the math.

I am seeing if I can still get the ohai portion to work by trying to round that info...time to revisit my Ruby course from last year :)

But for now here is what works:

def memory
  powershell_script "$ram" do
    code <<-eoh p="">    $computer = Get-WMIObject -class "Win32_ComputerSystem"
    $ram = [math]::Round($computer.TotalPhysicalMemory/1024/1024/1024/0)
    EOH
  end
end

if memory == 2
    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
elsif memory == 4
    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
elsif memory == 6
    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
elsif memory == 8
    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
else memory = 16
    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
  Chef::Log.error("Can't determine memory and set pagefile")
end

The code is on my github. I thought I'd share my findings.