Skip to content

(MODULES-3202) Fix install dependencies with custom source #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
26 changes: 18 additions & 8 deletions lib/puppet/provider/sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit* - this is PowerShell code, not 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the version of Windows (I believe 2008R2 is still supported here), /Alll may fail. Of course this change doesn't change this from what it was, so possibly a new ticket (which may already exist).

$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
6 changes: 3 additions & 3 deletions lib/puppet/provider/sqlserver_features/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ 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
if @resource[:features].empty?
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]
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/provider/sqlserver_instance/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ 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
if @resource[:features].empty?
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
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/sqlserver_features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.'

Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/sqlserver_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.'

Expand Down