Skip to content

Commit 3201af8

Browse files
Merge branch 'main' into CONT-490-add_support_sqlserver22
2 parents cc88e68 + f9a3dd2 commit 3201af8

17 files changed

+289
-46
lines changed

.fixtures.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ fixtures:
44
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
55
provision: 'https://github.com/puppetlabs/provision.git'
66
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
7+
mount_iso: 'https://github.com/puppetlabs/puppetlabs-mount_iso.git'
8+
archive: 'https://github.com/voxpupuli/puppet-archive.git'
79
symlinks:
810
sqlserver: "#{source_dir}"

.github/workflows/nightly.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: "nightly"
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
env:
8+
SERVICE_URL: https://facade-maint-config-windows-use-ssh-6f3kfepqcq-ew.a.run.app/v1/provision
9+
10+
jobs:
11+
setup_matrix:
12+
name: "Setup Test Matrix"
13+
runs-on: ubuntu-latest
14+
outputs:
15+
matrix: ${{ steps.get-matrix.outputs.matrix }}
16+
17+
steps:
18+
19+
- name: Checkout Source
20+
uses: actions/checkout@v2
21+
if: ${{ github.repository_owner == 'puppetlabs' }}
22+
23+
- name: Activate Ruby 2.7
24+
uses: ruby/setup-ruby@v1
25+
if: ${{ github.repository_owner == 'puppetlabs' }}
26+
with:
27+
ruby-version: "2.7"
28+
bundler-cache: true
29+
30+
- name: Print bundle environment
31+
if: ${{ github.repository_owner == 'puppetlabs' }}
32+
run: |
33+
echo ::group::bundler environment
34+
bundle env
35+
echo ::endgroup::
36+
37+
- name: Setup Acceptance Test Matrix
38+
id: get-matrix
39+
run: |
40+
bundle exec matrix_from_metadata_v2
41+
bundle exec matrix_from_metadata_v2
42+
43+
Acceptance:
44+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
45+
needs:
46+
- setup_matrix
47+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
48+
49+
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
53+
54+
55+
steps:
56+
57+
- name: Checkout Source
58+
uses: actions/checkout@v2
59+
60+
- name: Activate Ruby 2.7
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
ruby-version: "2.7"
64+
bundler-cache: true
65+
66+
- name: Print bundle environment
67+
run: |
68+
echo ::group::bundler environment
69+
bundle env
70+
echo ::endgroup::
71+
72+
- name: Provision test environment
73+
run: |
74+
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]"
75+
76+
- name: Install agent
77+
run: |
78+
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
79+
80+
- name: Install module
81+
run: |
82+
bundle exec rake 'litmus:install_module'
83+
84+
- name: Authenitcate with GCP
85+
run: |
86+
echo '${{ secrets.GCP_CONNECTION }}' >> creds.json
87+
bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
88+
bundle exec bolt command run "gcloud auth activate-service-account --key-file C:\\creds.json" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
89+
90+
- name: Download OS ISO
91+
run: |
92+
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/windows/en_windows_server_2019_updated_july_2020_x64_dvd_94453821.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
93+
94+
- name: Download SQLServer ISO
95+
run: |
96+
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/puppetlabs-sqlserver/SQLServer2019CTP2.4-x64-ENU.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
97+
98+
- name: Set Environment Variable
99+
run: |
100+
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
101+
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
102+
103+
- name: Run acceptance tests
104+
run: |
105+
bundle exec rake 'litmus:acceptance:parallel'
106+
107+
- name: Remove test environment
108+
if: ${{ always() }}
109+
continue-on-error: true
110+
run: |
111+
bundle exec rake 'litmus:tear_down'

.github/workflows/pr_test.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: "PR Testing"
2+
3+
on: [pull_request]
4+
5+
env:
6+
SERVICE_URL: https://facade-maint-config-windows-use-ssh-6f3kfepqcq-ew.a.run.app/v1/provision
7+
8+
jobs:
9+
setup_matrix:
10+
name: "Setup Test Matrix"
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.get-matrix.outputs.matrix }}
14+
15+
steps:
16+
17+
- name: Checkout Source
18+
uses: actions/checkout@v2
19+
if: ${{ github.repository_owner == 'puppetlabs' }}
20+
21+
- name: Activate Ruby 2.7
22+
uses: ruby/setup-ruby@v1
23+
if: ${{ github.repository_owner == 'puppetlabs' }}
24+
with:
25+
ruby-version: "2.7"
26+
bundler-cache: true
27+
28+
- name: Print bundle environment
29+
if: ${{ github.repository_owner == 'puppetlabs' }}
30+
run: |
31+
echo ::group::bundler environment
32+
bundle env
33+
echo ::endgroup::
34+
35+
- name: Setup Acceptance Test Matrix
36+
id: get-matrix
37+
run: |
38+
bundle exec matrix_from_metadata_v2
39+
bundle exec matrix_from_metadata_v2
40+
41+
Acceptance:
42+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
43+
needs:
44+
- setup_matrix
45+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
46+
47+
runs-on: ubuntu-latest
48+
strategy:
49+
fail-fast: false
50+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
51+
52+
53+
steps:
54+
55+
- name: Checkout Source
56+
uses: actions/checkout@v2
57+
58+
- name: Activate Ruby 2.7
59+
uses: ruby/setup-ruby@v1
60+
with:
61+
ruby-version: "2.7"
62+
bundler-cache: true
63+
64+
- name: Print bundle environment
65+
run: |
66+
echo ::group::bundler environment
67+
bundle env
68+
echo ::endgroup::
69+
70+
- name: Provision test environment
71+
run: |
72+
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]"
73+
74+
- name: Install agent
75+
run: |
76+
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
77+
78+
- name: Install module
79+
run: |
80+
bundle exec rake 'litmus:install_module'
81+
82+
- name: Authenitcate with GCP
83+
run: |
84+
echo '${{ secrets.GCP_CONNECTION }}' >> creds.json
85+
bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
86+
bundle exec bolt command run "gcloud auth activate-service-account --key-file C:\\creds.json" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
87+
88+
- name: Download OS ISO
89+
run: |
90+
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/windows/en_windows_server_2019_updated_july_2020_x64_dvd_94453821.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
91+
92+
- name: Download SQLServer ISO
93+
run: |
94+
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/puppetlabs-sqlserver/SQLServer2019CTP2.4-x64-ENU.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
95+
96+
- name: Set Environment Variable
97+
run: |
98+
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
99+
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
100+
101+
- name: Run acceptance tests
102+
run: |
103+
bundle exec rake 'litmus:acceptance:parallel'
104+
105+
- name: Remove test environment
106+
if: ${{ always() }}
107+
continue-on-error: true
108+
run: |
109+
bundle exec rake 'litmus:tear_down'

lib/puppet/provider/sqlserver_features/mssql.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def modify_features(action, features)
6565
'/IACCEPTSQLSERVERLICENSETERMS',
6666
"/FEATURES=#{features.join(',')}"]
6767
if action == 'install'
68+
cmd_args << '/UPDATEENABLED=False'
6869
if not_nil_and_not_empty?(@resource[:is_svc_account])
6970
cmd_args << "/ISSVCACCOUNT=#{@resource[:is_svc_account]}"
7071
end

lib/puppet/provider/sqlserver_instance/mssql.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def basic_cmd_args(features, action)
142142
'/IACCEPTSQLSERVERLICENSETERMS',
143143
"/INSTANCENAME=#{@resource[:name]}"]
144144
cmd_args << "/FEATURES=#{features.join(',')}" unless features.empty?
145+
cmd_args << '/UPDATEENABLED=False' if action == 'install'
146+
cmd_args
145147
end
146148

147149
def build_cmd_args(features, action = 'install')

lib/puppet_x/sqlserver/features.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def self.get_shared_features(version)
156156
'SDK_Full' => 'SDK', # Client Tools SDK
157157
'MDSCoreFeature' => 'MDS', # Master Data Services
158158
'Tools_Legacy_Full' => 'BC', # Client Tools Backwards Compatibility
159-
'SQL_SSMS_Full' => 'ADV_SSMS', # Management Tools - Complete (Does not exist in SQL 2016)
159+
'SQL_SSMS_Full' => 'ADV_SSMS', # Management Tools - Complete (Does not exist in SQL 2016+)
160160
'SQL_SSMS_Adv' => 'SSMS', # Management Tools - Basic (Does not exist in SQL 2016)
161161
'SQL_DQ_CLIENT_Full' => 'DQC', # Data Quality Client
162162
'SQL_BOL_Components' => 'BOL', # Documentation Components

spec/acceptance/sqlserver_config_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
describe 'sqlserver::config test' do
1313
def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
14+
user = Helper.instance.run_shell('$env:UserName').stdout.chomp
1415
pp = <<-MANIFEST
1516
sqlserver_instance{'#{inst_name}':
1617
ensure => '#{ensure_val}',
1718
source => 'H:',
1819
features => ['DQ', 'FullText', 'Replication', 'SQLEngine'],
19-
sql_sysadmin_accounts => ['Administrator'],
20+
sql_sysadmin_accounts => ['#{user}'],
2021
security_mode => 'SQL',
2122
sa_pwd => 'Pupp3t1@',
2223
windows_feature_source => 'I:\\sources\\sxs',
2324
}
2425
MANIFEST
25-
2626
apply_manifest(pp, catch_failures: true)
2727
end
2828

@@ -32,7 +32,7 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
3232
ensure_sqlserver_instance(inst_name)
3333

3434
# get credentials for new config
35-
@admin_user = 'admin' + SecureRandom.hex(2)
35+
@admin_user = 'test_user' + SecureRandom.hex(2)
3636
@admin_pass = 'Pupp3t1@'
3737

3838
# get database user
@@ -55,14 +55,14 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
5555
instance => '#{inst_name}',
5656
login_type => 'SQL_LOGIN',
5757
login => '#{@admin_user}',
58-
password => Sensitive('#{@admin_pass}'),
58+
password => '#{@admin_pass}',
5959
svrroles => {'sysadmin' => 1},
6060
}
6161
MANIFEST
6262
apply_manifest(pp, catch_failures: true)
6363
end
6464

65-
it 'Validate New Config WITH using instance_name in sqlserver::config' do
65+
it 'Validate New Config WITH instance_name in sqlserver::config' do
6666
pp = <<-MANIFEST
6767
sqlserver::config{'#{inst_name}':
6868
admin_user => Sensitive('#{@admin_user}'),
@@ -77,11 +77,11 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
7777
end
7878

7979
it 'Validate new login and database actualy created' do
80-
hostname = ENV['TARGET_HOST']
80+
hostname = Helper.instance.run_shell('hostname').stdout.upcase.strip
8181
query = "USE #{db_name}; SELECT * from master..sysdatabases WHERE name = '#{db_name}'"
8282

8383
run_sql_query(query: query, server: hostname, instance: inst_name, \
84-
sql_admin_user: @admin_user, sql_admin_pass: @admin_pass, expected_row_count: 1)
84+
sql_admin_user: @admin_user, sql_admin_pass: @admin_pass, expected_row_count: 1)
8585
end
8686

8787
it 'Validate New Config WITHOUT using instance_name in sqlserver::config' do

spec/acceptance/sqlserver_database_spec.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def run_sql_query_opts(query, expected_row_count)
4747
}
4848
sqlserver_tsql{'testsqlserver_tsql':
4949
instance => 'MSSQLSERVER',
50-
database => '#{@db_name}',
51-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
50+
command => "use #{@db_name}; CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
5251
require => Sqlserver::Database['#{@db_name}'],
5352
}
5453
MANIFEST
@@ -101,8 +100,7 @@ def run_sql_query_opts(query, expected_row_count)
101100
}
102101
sqlserver_tsql{'testsqlserver_tsql':
103102
instance => 'MSSQLSERVER',
104-
database => '#{@db_name}',
105-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
103+
command => "use #{@db_name};CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
106104
require => Sqlserver::Database['#{@db_name}'],
107105
}
108106
MANIFEST
@@ -132,8 +130,7 @@ def run_sql_query_opts(query, expected_row_count)
132130
}
133131
sqlserver_tsql{'testsqlserver_tsql':
134132
instance => 'MSSQLSERVER',
135-
database => '#{@db_name}',
136-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
133+
command => "use #{@db_name};CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
137134
require => Sqlserver::Database['#{@db_name}'],
138135
}
139136
MANIFEST
@@ -170,8 +167,7 @@ def run_sql_query_opts(query, expected_row_count)
170167
}
171168
sqlserver_tsql{'testsqlserver_tsql':
172169
instance => 'MSSQLSERVER',
173-
database => '#{@db_name}',
174-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
170+
command => "use #{@db_name};CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
175171
require => Sqlserver::Database['#{@db_name}'],
176172
}
177173
MANIFEST
@@ -209,8 +205,7 @@ def run_sql_query_opts(query, expected_row_count)
209205
}
210206
sqlserver_tsql{'testsqlserver_tsql':
211207
instance => 'MSSQLSERVER',
212-
database => '#{@db_name}',
213-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
208+
command => "use #{@db_name};CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
214209
require => Sqlserver::Database['#{@db_name}'],
215210
}
216211
MANIFEST
@@ -248,8 +243,7 @@ def run_sql_query_opts(query, expected_row_count)
248243
}
249244
sqlserver_tsql{'testsqlserver_tsql':
250245
instance => 'MSSQLSERVER',
251-
database => '#{@db_name}',
252-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
246+
command => "use #{@db_name};CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
253247
require => Sqlserver::Database['#{@db_name}'],
254248
}
255249
MANIFEST
@@ -287,8 +281,7 @@ def run_sql_query_opts(query, expected_row_count)
287281
}
288282
sqlserver_tsql{'testsqlserver_tsql':
289283
instance => 'MSSQLSERVER',
290-
database => '#{@db_name}',
291-
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
284+
command => "use #{@db_name};CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
292285
require => Sqlserver::Database['#{@db_name}'],
293286
}
294287
MANIFEST

0 commit comments

Comments
 (0)