diff --git a/README.md b/README.md index 7c30d035..c4fdd429 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,10 @@ Installs and configures features such as SSMS and Master Data Service. * `pid`: *Optional.* Supplies a product key to configure which edition of SQL Server to use. Valid options: a string containing a valid product key. Default: undef (if not specified, SQL Server runs in Evaluation mode). +* `source`: *Required.* Locates the SQL Server installer. Valid options: a string containing the path to an executable. Puppet must have permission to execute the installer. + +* `windows_feature_source`: *Optional.* Specifies the location of the Windows Feature source files. This may be needed to install the .Net Framework. See https://support.microsoft.com/en-us/kb/2734782 for more information. + Please note that if an option is set in both its own specific parameter and `install_switches`, the specifically named parameter takes precedence. For example, if you set the product key in both `pid` and in `install_switches`, SQL Server honors the `pid` parameter. For more information about installer switches and configuring SQL Server, see the links below: @@ -259,6 +263,8 @@ Installs and configures a SQL Server instance. * `sql_sysadmin_accounts`: *Required.* Specifies one or more SQL or system accounts to receive sysadmin status. Valid options: an array containing one or more valid usernames. +* `windows_feature_source`: *Optional.* Specifies the location of the Windows Feature source files. This may be needed to install the .Net Framework. See https://support.microsoft.com/en-us/kb/2734782 for more information. + Please note that if an option is set in both its own specific parameter and `install_switches`, the specifically named parameter takes precedence. For example, if you set the product key in both `pid` and in `install_switches`, SQL Server honors the `pid` parameter. For more information about installer switches and configuring SQL Server, see the links below: diff --git a/lib/puppet/provider/sqlserver.rb b/lib/puppet/provider/sqlserver.rb index 040993fa..6ca348b7 100644 --- a/lib/puppet/provider/sqlserver.rb +++ b/lib/puppet/provider/sqlserver.rb @@ -39,22 +39,32 @@ def not_nil_and_not_empty?(obj) !obj.nil? and !obj.empty? end - def self.run_install_dot_net - install_dot_net = <<-DOTNET -Install-WindowsFeature NET-Framework-Core + def self.run_install_dot_net(source_location = nil) + if (!source_location.nil?) + warn("The specified windows_source_location directory for sqlserver of \"#{source_location}\" does not exist") unless Puppet::FileSystem.directory?(source_location) + end -Write-Host "Installing .Net Framework 3.5, do not close this prompt..." -DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:$LocalSource | Out-Null + install_dot_net = <<-DOTNET $Result = Dism /online /Get-featureinfo /featurename:NetFx3 If($Result -contains "State : Enabled") { - Write-Host "Install .Net Framework 3.5 successfully." + Write-Host ".Net Framework 3.5 is already installed." } Else { - Write-Host "Failed to install Install .Net Framework 3.5,please make sure the local source is correct." + Write-Host "Installing .Net Framework 3.5, do not close this prompt..." + DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /NoRestart /Quiet /LimitAccess #{ "/Source:\"#{source_location}\"" unless source_location.nil? } | Out-Null + $Result = Dism /online /Get-featureinfo /featurename:NetFx3 + If($Result -contains "State : Enabled") + { + Write-Host "Install .Net Framework 3.5 successfully." + } + Else + { + Write-Host "Failed to install Install .Net Framework 3.5#{ ", please make sure the windows_feature_source is correct" unless source_location.nil?}." + } } - DOTNET +DOTNET powershell([install_dot_net]) end end diff --git a/lib/puppet/provider/sqlserver_features/mssql.rb b/lib/puppet/provider/sqlserver_features/mssql.rb index 1280f54b..13b26c96 100644 --- a/lib/puppet/provider/sqlserver_features/mssql.rb +++ b/lib/puppet/provider/sqlserver_features/mssql.rb @@ -99,8 +99,8 @@ def create_temp_for_install_switch return nil end - def installNet35 - result = Puppet::Provider::Sqlserver.run_install_dot_net + def installNet35(source_location = nil) + result = Puppet::Provider::Sqlserver.run_install_dot_net(source_location) end def create @@ -108,7 +108,7 @@ def create warn "Uninstalling all sql server features not tied into an instance because an empty array was passed, please use ensure absent instead." destroy else - installNet35 + installNet35(@resource[:windows_feature_source]) debug "Installing features #{@resource[:features]}" add_features(@resource[:features]) @property_hash[:features] = @resource[:features] diff --git a/lib/puppet/provider/sqlserver_instance/mssql.rb b/lib/puppet/provider/sqlserver_instance/mssql.rb index ad1a818a..d4cd41a8 100644 --- a/lib/puppet/provider/sqlserver_instance/mssql.rb +++ b/lib/puppet/provider/sqlserver_instance/mssql.rb @@ -57,8 +57,8 @@ def modify_features(features, action) end end - def installNet35 - result = Puppet::Provider::Sqlserver.run_install_dot_net + def installNet35(source_location = nil) + result = Puppet::Provider::Sqlserver.run_install_dot_net(source_location) end def create @@ -66,7 +66,7 @@ def create warn "Uninstalling all features for instance #{@resource[:name]} because an empty array was passed, please use ensure absent instead." destroy else - installNet35 + installNet35(@resource[:windows_feature_source]) add_features(@resource[:features]) # cmd_args = build_cmd_args(@resource[:features]) # begin diff --git a/lib/puppet/type/sqlserver_features.rb b/lib/puppet/type/sqlserver_features.rb index 55a8edfb..0e325ae0 100644 --- a/lib/puppet/type/sqlserver_features.rb +++ b/lib/puppet/type/sqlserver_features.rb @@ -14,6 +14,11 @@ newparam(:source) + newparam(:windows_feature_source) do + desc 'Specify the location of the Windows Feature source files. This may be needed to install the .Net Framework. + See https://support.microsoft.com/en-us/kb/2734782 for more information.' + end + newparam(:pid) do desc 'Specify the SQL Server product key to configure which edition you would like to use.' diff --git a/lib/puppet/type/sqlserver_instance.rb b/lib/puppet/type/sqlserver_instance.rb index 7ca7bfbb..179ff6c8 100644 --- a/lib/puppet/type/sqlserver_instance.rb +++ b/lib/puppet/type/sqlserver_instance.rb @@ -15,6 +15,11 @@ end + newparam(:windows_feature_source) do + desc 'Specify the location of the Windows Feature source files. This may be needed to install the .Net Framework. + See https://support.microsoft.com/en-us/kb/2734782 for more information.' + end + newparam(:pid) do desc 'Specify the SQL Server product key to configure which edition you would like to use.'