0

I've got a Chef cookbook from GitHub. It installs SQL Server 2012 Standard Edition. Our DBA has upgraded our database code to utilize features that can only be found on SQL Server 2012 Enterprise Edition. Since this cookbook is used to generate our test environments, we must now alter this cookbook to deploy SQL Server 2012 Enterprise.

Looking at the helper.rb file in the cookbook,

require 'chef/mixin/shell_out'

module SqlServer
  class Helper
    extend Chef::Mixin::ShellOut

    def self.firewall_rule_enabled?(rule_name=nil)
      cmd = shell_out("netsh advfirewall firewall show rule \"#{rule_name}\"")
      cmd.stderr.empty? && (cmd.stdout =~ /Enabled:\s*Yes/i)
    end

    def self.sql_server_url(version, x86_64)
      if x86_64
        case version
        when '2008R2'
          'http://download.microsoft.com/download/D/1/8/D1869DEC-2638-4854-81B7-0F37455F35EA/SQLEXPR_x64_ENU.exe'
        when '2012'
          'http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPR_x64_ENU.exe'
        end
      else
        case version
        when '2008R2'
          'http://download.microsoft.com/download/D/1/8/D1869DEC-2638-4854-81B7-0F37455F35EA/SQLEXPR32_x86_ENU.exe'
        when '2012'
          'http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x86/SQLEXPR_x86_ENU.exe'
        end
      end
    end

it seems that it gets the install media from

http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPR_x64_ENU.exe

When I look on MSDN (which we have access to) I don't see that the Enterprise Edition is available to download as a .EXE, only as an .ISO.

How can I alter this cookbook to deploy from an ISO instead of a EXE, assuming that I have full access to the ISO?

GWLlosa
  • 23,995
  • 17
  • 79
  • 116

2 Answers2

1

Re-write second half of the server.rb

Download the ISO from repo

remote_file 'C:\LocalPath' do
  source
end

Mount the ISO (you can also use Chef built-in mount resource)

powershell_script 'mount_it' do
  code <<-EOH
    Mount-DiskImage -ImagePath "C:\PATH\TO\ISO\FILE"
  EOH
end

Use MixLib::ShellOut and get the Drive name (if you don't have it hardcoded mount with a drive letter), replace the part ##### with the volume name.

output = Mixlib::ShellOut.new('(gwmi -Class Win32_LogicalDisk | Where-Object {$_.VolumeName -eq "#####"}).DeviceID')
drive_name = output.run_command.stdout

Once you know the drive the ISO mounts on, then you will be able to find the local path to the installation .EXE file.

Install using windows_package or powershell_script block

display name
  • 4,165
  • 2
  • 27
  • 52
  • OMG, donwloading the whole ISO ? why not extracting the .exe which is inside the ISO out of chef recipe ? – Tensibai Oct 05 '15 at 12:28
  • Extracting with third party software that may involve in compliance issue. You are welcome to add that to your posted answer. Great work, Tensibai. – display name Oct 05 '15 at 12:42
  • Or using the same method you described there... It's a matter of reading the ISO file to get the needed .exe file, I see no interest of transfering a ISO which 80% of content is of no use. (Already talked about this in the comments by the way) – Tensibai Oct 05 '15 at 12:44
  • In general, I find code sample helps out fellow SO users more than putting comments here and there, but I thank you for your collaboration on this. Awesome work. – display name Oct 05 '15 at 12:47
  • Code sample to mount an iso file and go to x64/Setup directory (if you're on a x64 machine) and pick the righ .msi for the flavor you wish ? FWIW, SO is not a help forum, this particular point (file extraction from ISO) would be better suited to http://superuser.stackexchange.com. Thanks for the compliments. – Tensibai Oct 05 '15 at 12:51
0

Quoting the attributes file from your link

# Set these to specify the URL, checksum, and package name. Otherwise, the cookbook will
# use default values based on the value of node['sql_server']['version'] and the
# server architecture (x86 or x64).

default['sql_server']['server']['url'] = nil
default['sql_server']['server']['checksum'] = nil
default['sql_server']['server']['package_name'] = nil

So you just have to set those values to a local package (on a internal http server for example) in a wrapper cookbook for this cookbook to install the enterprise version.

Tensibai
  • 15,557
  • 1
  • 37
  • 57
  • But what I have is the ISO... and I think the cookbook expects an EXE. How do I make that change? – GWLlosa Oct 02 '15 at 20:01