Skip to content

Commit ace9f91

Browse files
authored
Merge pull request #183 from glennsarti/ticket/master/MODULES-3202-fix-dism-source
(MODULES-3202) Fix install dependencies with custom source
2 parents 4c49240 + bbff759 commit ace9f91

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ Installs and configures features such as SSMS and Master Data Service.
204204

205205
* `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).
206206

207+
* `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.
208+
209+
* `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.
210+
207211
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.
208212

209213
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.
259263

260264
* `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.
261265

266+
* `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.
267+
262268
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.
263269

264270
For more information about installer switches and configuring SQL Server, see the links below:

lib/puppet/provider/sqlserver.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,32 @@ def not_nil_and_not_empty?(obj)
3939
!obj.nil? and !obj.empty?
4040
end
4141

42-
def self.run_install_dot_net
43-
install_dot_net = <<-DOTNET
44-
Install-WindowsFeature NET-Framework-Core
42+
def self.run_install_dot_net(source_location = nil)
43+
if (!source_location.nil?)
44+
warn("The specified windows_source_location directory for sqlserver of \"#{source_location}\" does not exist") unless Puppet::FileSystem.directory?(source_location)
45+
end
4546

46-
Write-Host "Installing .Net Framework 3.5, do not close this prompt..."
47-
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:$LocalSource | Out-Null
47+
install_dot_net = <<-DOTNET
4848
$Result = Dism /online /Get-featureinfo /featurename:NetFx3
4949
If($Result -contains "State : Enabled")
5050
{
51-
Write-Host "Install .Net Framework 3.5 successfully."
51+
Write-Host ".Net Framework 3.5 is already installed."
5252
}
5353
Else
5454
{
55-
Write-Host "Failed to install Install .Net Framework 3.5,please make sure the local source is correct."
55+
Write-Host "Installing .Net Framework 3.5, do not close this prompt..."
56+
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /NoRestart /Quiet /LimitAccess #{ "/Source:\"#{source_location}\"" unless source_location.nil? } | Out-Null
57+
$Result = Dism /online /Get-featureinfo /featurename:NetFx3
58+
If($Result -contains "State : Enabled")
59+
{
60+
Write-Host "Install .Net Framework 3.5 successfully."
61+
}
62+
Else
63+
{
64+
Write-Host "Failed to install Install .Net Framework 3.5#{ ", please make sure the windows_feature_source is correct" unless source_location.nil?}."
65+
}
5666
}
57-
DOTNET
67+
DOTNET
5868
powershell([install_dot_net])
5969
end
6070
end

lib/puppet/provider/sqlserver_features/mssql.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ def create_temp_for_install_switch
9999
return nil
100100
end
101101

102-
def installNet35
103-
result = Puppet::Provider::Sqlserver.run_install_dot_net
102+
def installNet35(source_location = nil)
103+
result = Puppet::Provider::Sqlserver.run_install_dot_net(source_location)
104104
end
105105

106106
def create
107107
if @resource[:features].empty?
108108
warn "Uninstalling all sql server features not tied into an instance because an empty array was passed, please use ensure absent instead."
109109
destroy
110110
else
111-
installNet35
111+
installNet35(@resource[:windows_feature_source])
112112
debug "Installing features #{@resource[:features]}"
113113
add_features(@resource[:features])
114114
@property_hash[:features] = @resource[:features]

lib/puppet/provider/sqlserver_instance/mssql.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ def modify_features(features, action)
5757
end
5858
end
5959

60-
def installNet35
61-
result = Puppet::Provider::Sqlserver.run_install_dot_net
60+
def installNet35(source_location = nil)
61+
result = Puppet::Provider::Sqlserver.run_install_dot_net(source_location)
6262
end
6363

6464
def create
6565
if @resource[:features].empty?
6666
warn "Uninstalling all features for instance #{@resource[:name]} because an empty array was passed, please use ensure absent instead."
6767
destroy
6868
else
69-
installNet35
69+
installNet35(@resource[:windows_feature_source])
7070
add_features(@resource[:features])
7171
# cmd_args = build_cmd_args(@resource[:features])
7272
# begin

lib/puppet/type/sqlserver_features.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
newparam(:source)
1616

17+
newparam(:windows_feature_source) do
18+
desc 'Specify the location of the Windows Feature source files. This may be needed to install the .Net Framework.
19+
See https://support.microsoft.com/en-us/kb/2734782 for more information.'
20+
end
21+
1722
newparam(:pid) do
1823
desc 'Specify the SQL Server product key to configure which edition you would like to use.'
1924

lib/puppet/type/sqlserver_instance.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
end
1717

18+
newparam(:windows_feature_source) do
19+
desc 'Specify the location of the Windows Feature source files. This may be needed to install the .Net Framework.
20+
See https://support.microsoft.com/en-us/kb/2734782 for more information.'
21+
end
22+
1823
newparam(:pid) do
1924
desc 'Specify the SQL Server product key to configure which edition you would like to use.'
2025

0 commit comments

Comments
 (0)