Skip to content

Commit 7f0f868

Browse files
authored
Merge pull request #420 from puppetlabs/CONT-490-add_support_sqlserver22
(CONT-490) - Add support for SQL Server 2022
2 parents f9a3dd2 + 3201af8 commit 7f0f868

File tree

10 files changed

+84
-33
lines changed

10 files changed

+84
-33
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
## Overview
2222

23-
The sqlserver module installs and manages Microsoft SQL Server 2012, 2014, 2016, 2017, 2019 on Windows systems.
23+
The sqlserver module installs and manages Microsoft SQL Server 2012, 2014, 2016, 2017, 2019 and 2022 on Windows systems.
2424

2525
## Module Description
2626

@@ -272,9 +272,9 @@ For information on the classes and types, see the [REFERENCE.md](https://github.
272272

273273
## Limitations
274274

275-
SQL 2017 and 2019 detection support has been added. This support is limited to functionality already present for other versions. No new SQL 2017 or above specific functionality has been added in this release.
275+
SQL 2017, 2019 and 2022 detection support has been added. This support is limited to functionality already present for other versions.
276276

277-
This module can manage only a single version of SQL Server on a given host (one and only one of SQL Server 2012, 2014, 2016, 2017, or 2019). The module is able to manage multiple SQL Server instances of the same version.
277+
This module can manage only a single version of SQL Server on a given host (one and only one of SQL Server 2012, 2014, 2016, 2017, 2019 or 2022). The module is able to manage multiple SQL Server instances of the same version.
278278

279279
This module cannot manage the SQL Server Native Client SDK (also known as SNAC_SDK). The SQL Server installation media can install the SDK, but it is not able to uninstall the SDK. Note that the 'sqlserver_features' fact detects the presence of the SDK.
280280

lib/puppet/provider/sqlserver_features/mssql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def create
128128
instance_version = PuppetX::Sqlserver::ServerHelper.sql_version_from_install_source(@resource[:source])
129129
Puppet.debug("Installation source detected as version #{instance_version}") unless instance_version.nil?
130130

131-
install_net_35(@resource[:windows_feature_source]) unless [SQL_2016, SQL_2017, SQL_2019].include? instance_version
131+
install_net_35(@resource[:windows_feature_source]) if [SQL_2012, SQL_2014].include? instance_version
132132

133133
debug "Installing features #{@resource[:features]}"
134134
add_features(@resource[:features])

lib/puppet/provider/sqlserver_instance/mssql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def create
105105
instance_version = PuppetX::Sqlserver::ServerHelper.sql_version_from_install_source(@resource[:source])
106106
Puppet.debug("Installation source detected as version #{instance_version}") unless instance_version.nil?
107107

108-
install_net_35(@resource[:windows_feature_source]) unless [SQL_2016, SQL_2017, SQL_2019].include? instance_version
108+
install_net_35(@resource[:windows_feature_source]) if [SQL_2012, SQL_2014].include? instance_version
109109

110110
add_features(@resource[:features])
111111
end

lib/puppet_x/sqlserver/features.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
SQL_2016 ||= 'SQL_2016'
88
SQL_2017 ||= 'SQL_2017'
99
SQL_2019 ||= 'SQL_2019'
10+
SQL_2022 ||= 'SQL_2022'
1011

11-
ALL_SQL_VERSIONS ||= [SQL_2012, SQL_2014, SQL_2016, SQL_2017, SQL_2019].freeze
12+
ALL_SQL_VERSIONS ||= [SQL_2012, SQL_2014, SQL_2016, SQL_2017, SQL_2019, SQL_2022].freeze
1213

1314
# rubocop:disable Style/ClassAndModuleChildren
1415
module PuppetX
@@ -39,6 +40,10 @@ class Features # rubocop:disable Style/Documentation
3940
major_version: 15,
4041
registry_path: '150',
4142
},
43+
SQL_2022 => {
44+
major_version: 16,
45+
registry_path: '160',
46+
},
4247
}.freeze
4348

4449
SQL_REG_ROOT ||= 'Software\Microsoft\Microsoft SQL Server'
@@ -145,6 +150,8 @@ def self.get_instance_features(reg_root, instance_name)
145150

146151
def self.get_shared_features(version)
147152
shared_features = {
153+
# Client tools support removed with SQLServer 2022
154+
# (ref https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-on-server-core?view=sql-server-ver16#BK_SupportedFeatures)
148155
'Connectivity_Full' => 'Conn', # Client Tools Connectivity
149156
'SDK_Full' => 'SDK', # Client Tools SDK
150157
'MDSCoreFeature' => 'MDS', # Master Data Services
@@ -156,7 +163,7 @@ def self.get_shared_features(version)
156163
'SQL_DReplay_Controller' => 'DREPLAY_CTLR', # Distributed Replay Controller
157164
'SQL_DReplay_Client' => 'DREPLAY_CLT', # Distributed Replay Client
158165
'sql_shared_mr' => 'SQL_SHARED_MR', # R Server (Standalone)
159-
166+
# SQL Client Connectivity SDK (Installed by default)
160167
# also WMI: SqlService WHERE SQLServiceType = 4 # MsDtsServer
161168
'SQL_DTS_Full' => 'IS', # Integration Services
162169
# currently ignoring Reporting Services Shared

lib/puppet_x/sqlserver/server_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def self.sql_version_from_install_source(source_dir)
4444
ver = content.match('"(.+)"')
4545
return nil if ver.nil?
4646

47+
return SQL_2022 if ver[1].start_with?('16.')
4748
return SQL_2019 if ver[1].start_with?('15.')
4849
return SQL_2017 if ver[1].start_with?('14.')
4950
return SQL_2016 if ver[1].start_with?('13.')

metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "puppetlabs-sqlserver",
33
"version": "3.2.1",
44
"author": "puppetlabs",
5-
"summary": "The `sqlserver` module installs and manages MS SQL Server 2012, 2014, 2016, 2017, and 2019 on Windows systems.",
5+
"summary": "The `sqlserver` module installs and manages MS SQL Server 2012, 2014, 2016, 2017, 2019 and 2022 on Windows systems.",
66
"license": "proprietary",
77
"source": "https://github.com/puppetlabs/puppetlabs-sqlserver",
88
"project_page": "https://github.com/puppetlabs/puppetlabs-sqlserver",
@@ -44,7 +44,8 @@
4444
"sql2014",
4545
"sql2016",
4646
"sql2017",
47-
"sql2019",
47+
"sql2019",
48+
"sql2022",
4849
"tsql",
4950
"database"
5051
],

spec/acceptance/z_last_sqlserver_features_spec.rb

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def ensure_sql_features(features, ensure_val = 'present')
1515

1616
pp = <<-MANIFEST
1717
sqlserver::config{ 'MSSQLSERVER':
18-
admin_pass => '<%= SQL_ADMIN_PASS %>',
19-
admin_user => '<%= SQL_ADMIN_USER %>',
18+
admin_pass => '<%= SQL_ADMIN_PASS %>',
19+
admin_user => '<%= SQL_ADMIN_USER %>',
2020
}
2121
sqlserver_features{ 'MSSQLSERVER':
2222
ensure => #{ensure_val},
@@ -35,8 +35,8 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
3535
user = Helper.instance.run_shell('$env:UserName').stdout.chomp
3636
pp = <<-MANIFEST
3737
sqlserver::config{ 'MSSQLSERVER':
38-
admin_pass => '<%= SQL_ADMIN_PASS %>',
39-
admin_user => '<%= SQL_ADMIN_USER %>',
38+
admin_pass => '<%= SQL_ADMIN_PASS %>',
39+
admin_user => '<%= SQL_ADMIN_USER %>',
4040
}
4141
sqlserver_features{ 'MSSQLSERVER':
4242
ensure => #{ensure_val},
@@ -50,7 +50,10 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
5050
end
5151

5252
context 'can install' do
53-
features = if version.to_i >= 2016
53+
# Client Tools removed in Server2022 (Backwards Compatibility, Connectivity, SDK)
54+
features = if version.to_i == 2022
55+
['IS', 'MDS', 'DQC']
56+
elsif version.to_i >= 2016 && version.to_i < 2022
5457
['BC', 'Conn', 'SDK', 'IS', 'MDS', 'DQC']
5558
else
5659
['BC', 'Conn', 'SSMS', 'ADV_SSMS', 'SDK', 'IS', 'MDS', 'DQC']
@@ -64,17 +67,22 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
6467
ensure_sql_features(features)
6568

6669
validate_sql_install(version: version) do |r|
67-
expect(r.stdout).to match(%r{Client Tools Connectivity})
68-
expect(r.stdout).to match(%r{Client Tools Backwards Compatibility})
69-
expect(r.stdout).to match(%r{Client Tools SDK})
70+
# Client Tools removed in Server2022
71+
unless version.to_i == 2022
72+
expect(r.stdout).to match(%r{Client Tools Connectivity})
73+
expect(r.stdout).to match(%r{Client Tools Backwards Compatibility})
74+
expect(r.stdout).to match(%r{Client Tools SDK})
75+
end
7076
expect(r.stdout).to match(%r{Integration Services})
7177
expect(r.stdout).to match(%r{Master Data Services})
7278
end
7379
end
7480
end
7581

7682
context 'can remove' do
77-
features = if version.to_i >= 2016
83+
features = if version.to_i == 2022
84+
['IS', 'MDS', 'DQC']
85+
elsif version.to_i >= 2016 && version.to_i < 2022
7886
['BC', 'Conn', 'SDK', 'IS', 'MDS', 'DQC']
7987
else
8088
['BC', 'Conn', 'SSMS', 'ADV_SSMS', 'SDK', 'IS', 'MDS', 'DQC']
@@ -84,17 +92,22 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
8492
ensure_sql_features(features, 'absent')
8593

8694
validate_sql_install(version: version) do |r|
87-
expect(r.stdout).not_to match(%r{Client Tools Connectivity})
88-
expect(r.stdout).not_to match(%r{Client Tools Backwards Compatibility})
89-
expect(r.stdout).not_to match(%r{Client Tools SDK})
95+
# Client Tools removed in Server2022
96+
unless version.to_i == 2022
97+
expect(r.stdout).not_to match(%r{Client Tools Connectivity})
98+
expect(r.stdout).not_to match(%r{Client Tools Backwards Compatibility})
99+
expect(r.stdout).not_to match(%r{Client Tools SDK})
100+
end
90101
expect(r.stdout).not_to match(%r{Integration Services})
91102
expect(r.stdout).not_to match(%r{Master Data Services})
92103
end
93104
end
94105
end
95106

96107
context 'can remove independent feature' do
97-
features = if version.to_i >= 2016
108+
features = if version.to_i == 2022
109+
['IS', 'MDS', 'DQC']
110+
elsif version.to_i >= 2016 && version.to_i < 2022
98111
['BC', 'Conn', 'SDK', 'IS', 'MDS', 'DQC']
99112
else
100113
['BC', 'Conn', 'SSMS', 'ADV_SSMS', 'SDK', 'IS', 'MDS', 'DQC']
@@ -108,7 +121,7 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
108121
ensure_sql_features(features, 'absent')
109122
end
110123

111-
it "'BC'" do
124+
it "'BC'", unless: version.to_i == 2022 do
112125
ensure_sql_features(features - ['BC'])
113126

114127
validate_sql_install(version: version) do |r|
@@ -127,7 +140,7 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
127140
end
128141
end
129142

130-
it "'SDK' + 'IS" do
143+
it "'SDK' + 'IS", unless: version.to_i == 2022 do
131144
ensure_sql_features(features - ['SDK', 'IS'])
132145

133146
validate_sql_install(version: version) do |r|
@@ -152,7 +165,13 @@ def bind_and_apply_failing_manifest(features, ensure_val = 'present')
152165
context 'with no installed instances' do
153166
# Currently this test can only be run on a machine once and will error if run a second time
154167
context 'can install' do
155-
features = ['BC', 'Conn', 'SDK', 'IS', 'MDS', 'DQC']
168+
features = if version.to_i == 2022
169+
['IS', 'MDS', 'DQC']
170+
elsif version.to_i >= 2016 && version.to_i < 2022
171+
['BC', 'Conn', 'SDK', 'IS', 'MDS', 'DQC']
172+
else
173+
['BC', 'Conn', 'SSMS', 'ADV_SSMS', 'SDK', 'IS', 'MDS', 'DQC']
174+
end
156175

157176
def remove_sql_instance
158177
user = Helper.instance.run_shell('$env:UserName').stdout.chomp

spec/spec_helper_acceptance_local.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Helper
1111
WIN_ISO_ROOT = 'https://artifactory.delivery.puppetlabs.net/artifactory/generic__iso/iso/windows'
1212
WIN_2019_ISO = 'en_windows_server_2019_updated_july_2020_x64_dvd_94453821.iso'
1313
QA_RESOURCE_ROOT = 'https://artifactory.delivery.puppetlabs.net/artifactory/generic__iso/iso/SQLServer'
14+
SQL_2022_ISO = 'SQLServer2022-x64-ENU-Dev.iso'
1415
SQL_2019_ISO = 'SQLServer2019CTP2.4-x64-ENU.iso'
1516
SQL_2017_ISO = 'SQLServer2017-x64-ENU.iso'
1617
SQL_2016_ISO = 'en_sql_server_2016_enterprise_with_service_pack_1_x64_dvd_9542382.iso'
@@ -120,6 +121,12 @@ def base_install(sql_version)
120121
file: SQL_2019_ISO,
121122
drive_letter: 'H',
122123
}
124+
when 2022
125+
iso_opts = {
126+
folder: QA_RESOURCE_ROOT,
127+
file: SQL_2022_ISO,
128+
drive_letter: 'H'
129+
}
123130
end
124131
# Mount the ISO on the agent
125132
mount_iso(iso_opts)
@@ -217,12 +224,14 @@ def validate_sql_install(opts = {}, &block)
217224
end
218225

219226
def get_install_paths(version)
220-
vers = { '2012' => '110', '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150' }
227+
vers = { '2012' => '110', '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150', '2022' => '160' }
221228

222229
raise _('Valid version must be specified') unless vers.keys.include?(version)
223230

224231
dir = "C://Program Files/Microsoft SQL Server/#{vers[version]}/Setup Bootstrap"
225232
sql_directory = case version
233+
when '2022'
234+
"SQL#{version}"
226235
when '2019'
227236
"SQL#{version}CTP2.4"
228237
when '2017'

spec/sql_testing_helpers.rb

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ def base_install(sql_version)
120120
file: SQL_2019_ISO,
121121
drive_letter: 'H',
122122
}
123+
when 2022
124+
iso_opts = {
125+
folder: QA_RESOURCE_ROOT,
126+
file: SQL_2022_ISO,
127+
drive_letter: 'H'
128+
}
123129
end
124130
host = find_only_one('sql_host')
125131
# Mount the ISO on the agent
@@ -162,15 +168,23 @@ def remove_sql_instances(host, opts = {})
162168
end
163169

164170
def get_install_paths(version)
165-
vers = { '2012' => '110', '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150' }
171+
vers = { '2012' => '110', '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150', '2022' => '160' }
166172

167173
raise _('Valid version must be specified') unless vers.keys.include?(version)
168174

169-
dir = "%ProgramFiles%\\Microsoft SQL Server\\#{vers[version]}\\Setup Bootstrap"
170-
sql_directory = 'SQL'
171-
sql_directory += 'Server' if version != '2017'
172-
173-
[dir, "#{dir}\\#{sql_directory}#{version}"]
175+
dir = "C://Program Files/Microsoft SQL Server/#{vers[version]}/Setup Bootstrap"
176+
sql_directory = case version
177+
when '2022'
178+
"SQL#{version}"
179+
when '2019'
180+
"SQL#{version}CTP2.4"
181+
when '2017'
182+
"SQL#{version}"
183+
else
184+
"SQLServer#{version}"
185+
end
186+
187+
[dir, "#{dir}\\#{sql_directory}"]
174188
end
175189

176190
def install_pe_license(host)

spec/unit/puppet_x/sql_connection_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def stub_connection
2424
context 'command execution' do
2525
before :each do
2626
stub_connection
27-
allow(@connection).to receive(:Open).with('Provider=MSOLEDBSQL;Initial Catalog=master;Application Name=Puppet;Data Source=.;DataTypeComptibility=80;User ID=sa;Password=Pupp3t1@')
27+
allow(@connection).to receive(:Open).with('Provider=MSOLEDBSQL;Initial Catalog=master;Application Name=Puppet;Data Source=.;DataTypeComptibility=80;UID=sa;PWD=Pupp3t1@')
2828
end
2929
it 'does not raise an error but populate has_errors with message' do
3030
allow(@connection.Errors).to receive(:count).and_return(2)

0 commit comments

Comments
 (0)