From 5630c7db0e39f9339a508fd43e6a1fbbfe3d691b Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Fri, 28 Apr 2023 09:22:31 +0100 Subject: [PATCH 01/43] (MAINT) - Remove deprecated 'has_key' --- manifests/login.pp | 8 ++++---- manifests/role.pp | 8 ++++---- manifests/user.pp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifests/login.pp b/manifests/login.pp index 45c881f6..7d226c39 100644 --- a/manifests/login.pp +++ b/manifests/login.pp @@ -92,25 +92,25 @@ instance => $instance, require => Sqlserver_tsql["login-${instance}-${login}"], } - if has_key($_upermissions, 'GRANT') and $_upermissions['GRANT'] =~ Array { + if 'GRANT' in $_upermissions and $_upermissions['GRANT'] =~ Array { sqlserver::login::permissions { "Sqlserver::Login[${title}]-GRANT-${login}": state => 'GRANT', permissions => $_upermissions['GRANT'], } } - if has_key($_upermissions, 'DENY') and $_upermissions['DENY'] =~ Array { + if 'DENY' in $_upermissions and $_upermissions['DENY'] =~ Array { sqlserver::login::permissions { "Sqlserver::Login[${title}]-DENY-${login}": state => 'DENY', permissions => $_upermissions['DENY'], } } - if has_key($_upermissions, 'REVOKE') and $_upermissions['REVOKE'] =~ Array { + if 'REVOKE' in $_upermissions and $_upermissions['REVOKE'] =~ Array { sqlserver::login::permissions { "Sqlserver::Login[${title}]-REVOKE-${login}": state => 'REVOKE', permissions => $_upermissions['REVOKE'], } } - if has_key($_upermissions, 'GRANT_WITH_OPTION') and $_upermissions['GRANT_WITH_OPTION'] =~ Array { + if 'GRANT_WITH_OPTION' in $_upermissions and $_upermissions['GRANT_WITH_OPTION'] =~ Array { sqlserver::login::permissions { "Sqlserver::Login[${title}]-GRANT-WITH_GRANT_OPTION-${login}": state => 'GRANT', with_grant_option => true, diff --git a/manifests/role.pp b/manifests/role.pp index 82aa96fd..f3967106 100644 --- a/manifests/role.pp +++ b/manifests/role.pp @@ -79,25 +79,25 @@ type => $type, require => Sqlserver_tsql[$sqlserver_tsql_title], } - if has_key($_upermissions, 'GRANT') and $_upermissions['GRANT'] =~ Array { + if 'GRANT' in $_upermissions and $_upermissions['GRANT'] =~ Array { sqlserver::role::permissions { "Sqlserver::Role[${title}]-GRANT-${role}": state => 'GRANT', permissions => $_upermissions['GRANT'], } } - if has_key($_upermissions, 'DENY') and $_upermissions['DENY'] =~ Array { + if 'DENY' in $_upermissions and $_upermissions['DENY'] =~ Array { sqlserver::role::permissions { "Sqlserver::Role[${title}]-DENY-${role}": state => 'DENY', permissions => $_upermissions['DENY'], } } - if has_key($_upermissions, 'REVOKE') and $_upermissions['REVOKE'] =~ Array { + if 'REVOKE' in $_upermissions and $_upermissions['REVOKE'] =~ Array { sqlserver::role::permissions { "Sqlserver::Role[${title}]-REVOKE-${role}": state => 'REVOKE', permissions => $_upermissions['REVOKE'], } } - if has_key($_upermissions, 'GRANT_WITH_OPTION') and $_upermissions['GRANT_WITH_OPTION'] =~ Array { + if 'GRANT_WITH_OPTION' in $_upermissions and $_upermissions['GRANT_WITH_OPTION'] =~ Array { sqlserver::role::permissions { "Sqlserver::Role[${title}]-GRANT-WITH_GRANT_OPTION-${role}": state => 'GRANT', with_grant_option => true, diff --git a/manifests/user.pp b/manifests/user.pp index 529d466a..fbdbec5b 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -79,25 +79,25 @@ instance => $instance, require => Sqlserver_tsql["user-${instance}-${database}-${user}"], } - if has_key($_upermissions, 'GRANT') and $_upermissions['GRANT'] =~ Array { + if 'GRANT' in $_upermissions and $_upermissions['GRANT'] =~ Array { sqlserver::user::permissions { "Sqlserver::User[${title}]-GRANT-${user}": state => 'GRANT', permissions => $_upermissions['GRANT'], } } - if has_key($_upermissions, 'DENY') and $_upermissions['DENY'] =~ Array { + if 'DENY' in $_upermissions and $_upermissions['DENY'] =~ Array { sqlserver::user::permissions { "Sqlserver::User[${title}]-DENY-${user}": state => 'DENY', permissions => $_upermissions['DENY'], } } - if has_key($_upermissions, 'REVOKE') and $_upermissions['REVOKE'] =~ Array { + if 'REVOKE' in $_upermissions and $_upermissions['REVOKE'] =~ Array { sqlserver::user::permissions { "Sqlserver::User[${title}]-REVOKE-${user}": state => 'REVOKE', permissions => $_upermissions['REVOKE'], } } - if has_key($_upermissions, 'GRANT_WITH_OPTION') and $_upermissions['GRANT_WITH_OPTION'] =~ Array { + if 'GRANT_WITH_OPTION' in $_upermissions and $_upermissions['GRANT_WITH_OPTION'] =~ Array { sqlserver::user::permissions { "Sqlserver::User[${title}]-GRANT-WITH_GRANT_OPTION-${user}": state => 'GRANT', with_grant_option => true, From dbc90e143f22150de0db0a5b17771cf667656d29 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Mon, 15 May 2023 14:17:43 +0100 Subject: [PATCH 02/43] (CONT-930) - Roll out new changelog generator --- .github/workflows/auto_release.yml | 9 --------- .github/workflows/release_prep.yml | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 .github/workflows/auto_release.yml create mode 100644 .github/workflows/release_prep.yml diff --git a/.github/workflows/auto_release.yml b/.github/workflows/auto_release.yml deleted file mode 100644 index d6270c56..00000000 --- a/.github/workflows/auto_release.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: "Auto release" - -on: - workflow_dispatch: - -jobs: - release_prep: - uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main" - secrets: "inherit" diff --git a/.github/workflows/release_prep.yml b/.github/workflows/release_prep.yml new file mode 100644 index 00000000..bb0b7acc --- /dev/null +++ b/.github/workflows/release_prep.yml @@ -0,0 +1,15 @@ +name: "Release Prep" + +on: + workflow_dispatch: + inputs: + version: + description: "Module version to be released. Must be a valid semver string. (1.2.3)" + required: true + +jobs: + release_prep: + uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main" + with: + version: "${{ github.event.inputs.version }}" + secrets: "inherit" From bf09d521849fef39d3f0a93855340c357f2d5247 Mon Sep 17 00:00:00 2001 From: Gavin Patton Date: Thu, 18 May 2023 09:14:21 +0100 Subject: [PATCH 03/43] (CONT-985) Address deprecation warnings Prior to this commit, there were deprecation warnings in the github action workflows regarding use of checkout@v2. This commit uses v3. --- .github/workflows/ci.yml | 4 ++-- .github/workflows/nightly.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d665b03..815c2451 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout Source - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 @@ -63,7 +63,7 @@ jobs: steps: - name: Checkout Source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4a2c7cae..4878d009 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout Source - uses: actions/checkout@v2 + uses: actions/checkout@v3 if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 @@ -61,7 +61,7 @@ jobs: steps: - name: Checkout Source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 From 044cfd8cf1bf65be5df8317622132458a0c8e917 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Wed, 17 May 2023 15:38:29 +0530 Subject: [PATCH 04/43] (CONT-567) allow deferred function for password --- lib/puppet/functions/sqlserver/password.rb | 13 +++++ manifests/login.pp | 14 ++++- manifests/user.pp | 10 +++- metadata.json | 2 +- spec/functions/password_spec.rb | 8 +++ templates/create/login.sql.epp | 58 +++++++++++++++++++ templates/create/login.sql.erb | 58 ------------------- templates/create/user.sql.epp | 18 ++++++ templates/create/user.sql.erb | 18 ------ .../delete/{login.sql.erb => login.sql.epp} | 4 +- templates/delete/user.sql.epp | 4 ++ templates/delete/user.sql.erb | 4 -- 12 files changed, 126 insertions(+), 85 deletions(-) create mode 100644 lib/puppet/functions/sqlserver/password.rb create mode 100644 spec/functions/password_spec.rb create mode 100644 templates/create/login.sql.epp delete mode 100644 templates/create/login.sql.erb create mode 100644 templates/create/user.sql.epp delete mode 100644 templates/create/user.sql.erb rename templates/delete/{login.sql.erb => login.sql.epp} (85%) create mode 100644 templates/delete/user.sql.epp delete mode 100644 templates/delete/user.sql.erb diff --git a/lib/puppet/functions/sqlserver/password.rb b/lib/puppet/functions/sqlserver/password.rb new file mode 100644 index 00000000..8abf0b88 --- /dev/null +++ b/lib/puppet/functions/sqlserver/password.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# This function exists for usage of a role password that is a deferred function +Puppet::Functions.create_function(:'sqlserver::password') do + dispatch :password do + optional_param 'Any', :pass + return_type 'Any' + end + + def password(pass) + pass + end +end diff --git a/manifests/login.pp b/manifests/login.pp index 7d226c39..c09abdf3 100644 --- a/manifests/login.pp +++ b/manifests/login.pp @@ -76,9 +76,21 @@ 'absent' => 'delete', } + $parameters = { + 'password' => Deferred('sqlserver::password', [$password]), + 'disabled' => $disabled, + 'login_type' => $login_type, + 'login' => $login, + 'default_language' => $default_language, + 'default_database' => $default_database, + 'check_policy' => $check_policy, + 'check_expiration' => $check_expiration, + 'svrroles' => $svrroles, + } + sqlserver_tsql { "login-${instance}-${login}": instance => $instance, - command => template("sqlserver/${_create_delete}/login.sql.erb"), + command => stdlib::deferrable_epp("sqlserver/${_create_delete}/login.sql.epp", $parameters), onlyif => template('sqlserver/query/login_exists.sql.erb'), require => Sqlserver::Config[$instance], } diff --git a/manifests/user.pp b/manifests/user.pp index fbdbec5b..50974b0d 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -62,9 +62,17 @@ 'absent' => 'delete', } + $parameters = { + 'password' => Deferred('sqlserver::password', [$password]), + 'database' => $database, + 'user' => $user, + 'login' => $login, + 'default_schema' => $default_schema, + } + sqlserver_tsql { "user-${instance}-${database}-${user}": instance => $instance, - command => template("sqlserver/${create_delete}/user.sql.erb"), + command => stdlib::deferrable_epp("sqlserver/${create_delete}/user.sql.epp", $parameters), onlyif => template('sqlserver/query/user_exists.sql.erb'), require => Sqlserver::Config[$instance], } diff --git a/metadata.json b/metadata.json index c4209d67..789760c1 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.13.1 < 9.0.0" + "version_requirement": ">= 8.4.0 < 9.0.0" }, { "name": "puppetlabs/powershell", diff --git a/spec/functions/password_spec.rb b/spec/functions/password_spec.rb new file mode 100644 index 00000000..54010644 --- /dev/null +++ b/spec/functions/password_spec.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'sqlserver::password' do + it { is_expected.to run.with_params('password').and_return('password') } + it { is_expected.to run.with_params(nil).and_return(nil) } +end diff --git a/templates/create/login.sql.epp b/templates/create/login.sql.epp new file mode 100644 index 00000000..a7f93c49 --- /dev/null +++ b/templates/create/login.sql.epp @@ -0,0 +1,58 @@ +DECLARE + @is_disabled as tinyint = <%= if $disabled {1} else {0} %>, + @login_type as varchar(255) = NULL; + +SET @login_type = (SELECT [type] FROM sys.server_principals where name = '<%= $login %>') +IF (@login_type IS NULL) +BEGIN + -- Create the login + CREATE LOGIN [<%= $login %>] + <% if $login_type !~ /WINDOWS_LOGIN/ { -%> + WITH + PASSWORD = '<%= $password %>', + CHECK_EXPIRATION = <% if $check_expiration { %>ON<% } else { %>OFF<% } %>, + CHECK_POLICY = <% if $check_policy { %>ON<% } else { %>OFF<% } %>, + <% } else { -%> + FROM WINDOWS WITH + <% } -%> + DEFAULT_LANGUAGE = [<%= $default_language %>], + DEFAULT_DATABASE = [<%= $default_database %>]; + -- Fetch the login type + SET @login_type = (SELECT [type] FROM sys.server_principals where name = '<%= $login %>') +END + +IF (@login_type = 'G') +BEGIN + -- Windows Group type logins can only be granted/denied connection + IF @is_disabled = 0 GRANT CONNECT SQL TO [<%= $login %>] + ELSE DENY CONNECT SQL TO [<%= $login %>] +END +ELSE +BEGIN + IF @is_disabled = 0 ALTER LOGIN [<%= $login %>] ENABLE + ELSE ALTER LOGIN [<%= $login %>] DISABLE +END + +ALTER LOGIN [<%= $login %>] WITH +<% if $login_type != 'WINDOWS_LOGIN' { -%> + CHECK_EXPIRATION = <% if $check_expiration { %>ON<% } else { %>OFF<% } %>, + CHECK_POLICY = <% if $check_policy { %>ON<% } else { %>OFF<% } %>, +<% } -%> + DEFAULT_LANGUAGE = [<%= $default_language %>], + DEFAULT_DATABASE = [<%= $default_database %>]; + +<% $svrroles.each |String $role, Any $enable_bit| { -%> +IF (SELECT COUNT(me.role_principal_id) from sys.server_role_members me + JOIN sys.server_principals rol ON me.role_principal_id = rol.principal_id + JOIN sys.server_principals pri ON me.member_principal_id = pri.principal_id + WHERE rol.type_desc = 'SERVER_ROLE' + AND rol.name = '<%= $role %>' + AND pri.name = '<%= $login %>') != <%= $enable_bit %> +BEGIN + <% if ($enable_bit == '1') or ($enable_bit == 1) { -%> + ALTER SERVER ROLE [<%= $role %>] ADD MEMBER [<%= $login %>]; + <% } else { -%> + ALTER SERVER ROLE [<%= $role %>] DROP MEMBER [<%= $login %>]; + <% } -%> +END +<% } -%> diff --git a/templates/create/login.sql.erb b/templates/create/login.sql.erb deleted file mode 100644 index 58a3a842..00000000 --- a/templates/create/login.sql.erb +++ /dev/null @@ -1,58 +0,0 @@ -DECLARE - @is_disabled as tinyint = <%= @disabled ? 1 : 0 %>, - @login_type as varchar(255) = NULL; - -SET @login_type = (SELECT [type] FROM sys.server_principals where name = '<%= @login %>') -IF (@login_type IS NULL) -BEGIN - -- Create the login - CREATE LOGIN [<%= @login %>] - <% if @login_type !~ /WINDOWS_LOGIN/i -%> - WITH - PASSWORD = '<%= @password %>', - CHECK_EXPIRATION = <% if @check_expiration %>ON<% else %>OFF<% end %>, - CHECK_POLICY = <% if @check_policy %>ON<% else %>OFF<% end %>, - <% else -%> - FROM WINDOWS WITH - <% end -%> - DEFAULT_LANGUAGE = [<%= @default_language %>], - DEFAULT_DATABASE = [<%= @default_database %>]; - -- Fetch the login type - SET @login_type = (SELECT [type] FROM sys.server_principals where name = '<%= @login %>') -END - -IF (@login_type = 'G') -BEGIN - -- Windows Group type logins can only be granted/denied connection - IF @is_disabled = 0 GRANT CONNECT SQL TO [<%= @login %>] - ELSE DENY CONNECT SQL TO [<%= @login %>] -END -ELSE -BEGIN - IF @is_disabled = 0 ALTER LOGIN [<%= @login %>] ENABLE - ELSE ALTER LOGIN [<%= @login %>] DISABLE -END - -ALTER LOGIN [<%= @login %>] WITH -<% if @login_type != 'WINDOWS_LOGIN' -%> - CHECK_EXPIRATION = <% if @check_expiration %>ON<% else %>OFF<% end %>, - CHECK_POLICY = <% if @check_policy %>ON<% else %>OFF<% end %>, -<% end -%> - DEFAULT_LANGUAGE = [<%= @default_language %>], - DEFAULT_DATABASE = [<%= @default_database %>]; - -<% @svrroles.each do |role, enable_bit| -%> -IF (SELECT COUNT(me.role_principal_id) from sys.server_role_members me - JOIN sys.server_principals rol ON me.role_principal_id = rol.principal_id - JOIN sys.server_principals pri ON me.member_principal_id = pri.principal_id - WHERE rol.type_desc = 'SERVER_ROLE' - AND rol.name = '<%= role %>' - AND pri.name = '<%= @login %>') != <%= enable_bit %> -BEGIN - <% if enable_bit == '1' || enable_bit == 1 -%> - ALTER SERVER ROLE [<%= role %>] ADD MEMBER [<%= @login %>]; - <% else -%> - ALTER SERVER ROLE [<%= role %>] DROP MEMBER [<%= @login %>]; - <% end -%> -END -<% end -%> diff --git a/templates/create/user.sql.epp b/templates/create/user.sql.epp new file mode 100644 index 00000000..d813b30c --- /dev/null +++ b/templates/create/user.sql.epp @@ -0,0 +1,18 @@ +USE [<%= $database %>]; +<% if $password { %> + IF EXISTS(select containment from sys.databases WHERE name = '<%= $database %>' AND containment = 0) + THROW 51000, 'Database must be contained in order to use passwords', 10 +<% } %> +CREATE USER [<%= $user %>] +<% if $login { -%> + FROM LOGIN [<%= $login %>] +<% } else { -%> + <% if $password { -%> + WITH PASSWORD = '<%= $password %>' + <% } -%> +<% } -%> +<% if $default_schema { -%> + <% if $password { -%>,<% } else { -%> + WITH <% } -%> + DEFAULT_SCHEMA = <%= $default_schema %> +<% } -%> diff --git a/templates/create/user.sql.erb b/templates/create/user.sql.erb deleted file mode 100644 index b92616e3..00000000 --- a/templates/create/user.sql.erb +++ /dev/null @@ -1,18 +0,0 @@ -USE [<%= @database %>]; -<% if @password %> - IF EXISTS(select containment from sys.databases WHERE name = '<%= @database %>' AND containment = 0) - THROW 51000, 'Database must be contained in order to use passwords', 10 -<% end %> -CREATE USER [<%= @user %>] -<% if @login -%> - FROM LOGIN [<%= @login %>] -<% else -%> - <% if @password -%> - WITH PASSWORD = '<%= @password %>' - <% end -%> -<% end -%> -<% if @default_schema -%> - <% if @password -%>,<% else -%> - WITH <% end -%> - DEFAULT_SCHEMA = <%= @default_schema %> -<% end -%> diff --git a/templates/delete/login.sql.erb b/templates/delete/login.sql.epp similarity index 85% rename from templates/delete/login.sql.erb rename to templates/delete/login.sql.epp index df8edac4..d91b00c2 100644 --- a/templates/delete/login.sql.erb +++ b/templates/delete/login.sql.epp @@ -1,7 +1,7 @@ USE master; -IF exists(select * from sys.server_principals where name = '<%= @login %>') +IF exists(select * from sys.server_principals where name = '<%= $login %>') BEGIN -- need to add logic to kill all possible connections if any exists, -- possible force flag to prevent from happening during transaction if user would prefer to wait - DROP LOGIN [<%= @login %>] + DROP LOGIN [<%= $login %>] END diff --git a/templates/delete/user.sql.epp b/templates/delete/user.sql.epp new file mode 100644 index 00000000..f6b4ddf6 --- /dev/null +++ b/templates/delete/user.sql.epp @@ -0,0 +1,4 @@ +USE [<%= $database %>]; +DROP USER [<%= $user %>]; +IF EXISTS(SELECT name FROM sys.database_principals WHERE name = '<%= $user %>') + THROW 51000, 'Failed to drop user <%= $user %>', 10 diff --git a/templates/delete/user.sql.erb b/templates/delete/user.sql.erb deleted file mode 100644 index fffdbe7d..00000000 --- a/templates/delete/user.sql.erb +++ /dev/null @@ -1,4 +0,0 @@ -USE [<%= @database %>]; -DROP USER [<%= @user %>]; -IF EXISTS(SELECT name FROM sys.database_principals WHERE name = '<%= @user %>') - THROW 51000, 'Failed to drop user <%= @user %>', 10 From e3405be5860dcf01ea3a14c7a72c32400df1f378 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Thu, 25 May 2023 10:23:22 +0530 Subject: [PATCH 05/43] Bumping up puppet_litmus gem to ~> 1.0 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2f7e2ff7..918691c7 100644 --- a/Gemfile +++ b/Gemfile @@ -38,7 +38,7 @@ group :development do gem "github_changelog_generator", '= 1.15.2', require: false end group :system_tests do - gem "puppet_litmus", '< 1.0.0', require: false, platforms: [:ruby, :x64_mingw] + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] gem "serverspec", '~> 2.41', require: false end From a68ed8eeba1c051793d1c3624dbfdd6b0e149e65 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Tue, 30 May 2023 17:13:30 +0100 Subject: [PATCH 06/43] (CONT-1028) - Update Stdlib upper limit dependency --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 789760c1..85af53b6 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 8.4.0 < 9.0.0" + "version_requirement": ">= 8.4.0 < 10.0.0" }, { "name": "puppetlabs/powershell", From 92c01207733c80cb8066b023d7593a7922bc21fe Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Thu, 15 Jun 2023 17:15:45 +0530 Subject: [PATCH 07/43] (CONT-990) - Community Pull Requests template --- .github/pull_request_template.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..e3a97007 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +## Summary +Provide a detailed description of all the changes present in this pull request. + +## Additional Context +Add any additional context about the problem here. +- [ ] Root cause and the steps to reproduce. (If applicable) +- [ ] Thought process behind the implementation. + +## Related Issues (if any) +Mention any related issues or pull requests. + +## Checklist +- [ ] 🟢 Spec tests. +- [ ] 🟢 Acceptance tests. +- [ ] Manually verified. (For example `puppet apply`) \ No newline at end of file From 1d7fd45ecc3bda1eca7964eddd0d7531474d9736 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 27 Jun 2023 09:05:22 +0000 Subject: [PATCH 08/43] Release prep v4.1.0 --- CHANGELOG.md | 575 ++++++++++++++++++++++++++++++-------------------- metadata.json | 2 +- 2 files changed, 342 insertions(+), 235 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b5b552..bac7bb12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,339 +1,446 @@ -# Change log + +# Changelog -All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +All notable changes to this project will be documented in this file. -## [v4.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v4.0.0) (2023-04-26) +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.3.0...v4.0.0) - -### Changed - -- \(CONT-800\) - Add Puppet 8/Drop Puppet 6 [\#430](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/430) ([jordanbreen28](https://github.com/jordanbreen28)) +## [v4.1.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v4.1.0) - 2023-06-27 -## [v3.3.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.3.0) (2023-03-07) - -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.2.1...v3.3.0) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v4.0.0...v4.1.0) ### Added -- \(CONT-490\) - Add support for SQL Server 2022 [\#420](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/420) ([jordanbreen28](https://github.com/jordanbreen28)) +- pdksync - (MAINT) - Allow Stdlib 9.x [#438](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/438) ([LukasAud](https://github.com/LukasAud)) +- (CONT-567) allow deferred function for password [#436](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/436) ([Ramesh7](https://github.com/Ramesh7)) -## [v3.2.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.2.1) (2022-12-13) +## [v4.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v4.0.0) - 2023-04-26 -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.2.0...v3.2.1) - -### Fixed +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.3.0...v4.0.0) -- \(CONT-370\) Reinstate lost sqlserver documentation on feature & tool deprecations [\#412](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/412) ([GSPatton](https://github.com/GSPatton)) +### Changed +- (CONT-800) - Add Puppet 8/Drop Puppet 6 [#430](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/430) ([jordanbreen28](https://github.com/jordanbreen28)) -## [v3.2.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.2.0) (2022-08-23) +## [v3.3.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.3.0) - 2023-03-07 -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.1.0...v3.2.0) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.2.1...v3.3.0) ### Added -- \(CAT-136\) Update dependencies [\#405](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/405) ([LukasAud](https://github.com/LukasAud)) +- (CONT-490) - Add support for SQL Server 2022 [#420](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/420) ([jordanbreen28](https://github.com/jordanbreen28)) ### Fixed -- Fix puppet strings formatting [\#414](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/414) ([GSPatton](https://github.com/GSPatton)) +- Fix puppet strings formatting [#414](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/414) ([GSPatton](https://github.com/GSPatton)) -## [v3.1.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.1.0) (2022-05-30) +## [v3.2.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.2.1) - 2022-12-13 -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.0.0...v3.1.0) - -### Added - -- pdksync - \(FM-8922\) - Add Support for Windows 2022 [\#397](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/397) ([david22swan](https://github.com/david22swan)) -- \(MODULES-5472\) Login values can now be passed as sensitive strings [\#393](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/393) ([david22swan](https://github.com/david22swan)) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.2.0...v3.2.1) ### Fixed -- \(MODULES-10825\) - Dotnet installation fix [\#392](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/392) ([david22swan](https://github.com/david22swan)) - -## [v3.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.0.0) (2021-02-27) +- (CONT-370) Reinstate lost sqlserver documentation on feature & tool deprecations [#412](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/412) ([GSPatton](https://github.com/GSPatton)) -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.2...v3.0.0) +## [v3.2.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.2.0) - 2022-08-23 -### Changed - -- pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [\#369](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/369) ([carabasdaniel](https://github.com/carabasdaniel)) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.1.0...v3.2.0) ### Added -- pdksync - \(feat\) - Add support for Puppet 7 [\#363](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/363) ([daianamezdrea](https://github.com/daianamezdrea)) - -### Fixed - -- \(FM-8879\) Handle T-SQL Errors Properly [\#349](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/349) ([RandomNoun7](https://github.com/RandomNoun7)) +- (CAT-136) Update dependencies [#405](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/405) ([LukasAud](https://github.com/LukasAud)) -## [v2.6.2](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.6.2) (2020-01-21) +## [v3.1.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.1.0) - 2022-05-30 -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.1...v2.6.2) - -### Fixed - -- \(MODULES-10384\) - Registry value check tightened [\#343](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/343) ([david22swan](https://github.com/david22swan)) -- \(MODULES-10335\) - Update exec's title to be unique [\#341](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/341) ([david22swan](https://github.com/david22swan)) - -## [v2.6.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.6.1) (2020-01-16) - -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.0...v2.6.1) - -### Fixed - -- \(MODULES-10388\) fix missing gem [\#339](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/339) ([sheenaajay](https://github.com/sheenaajay)) - -## [v2.6.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.6.0) (2019-10-21) - -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.5.1...v2.6.0) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.0.0...v3.1.0) ### Added -- Add support for Server 2019 [\#327](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/327) ([sanfrancrisko](https://github.com/sanfrancrisko)) - -## v2.5.1 +- pdksync - (FM-8922) - Add Support for Windows 2022 [#397](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/397) ([david22swan](https://github.com/david22swan)) +- (MODULES-5472) Login values can now be passed as sensitive strings [#393](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/393) ([david22swan](https://github.com/david22swan)) ### Fixed -- Add DQC to sqlserver_features feature attribute ([MODULES-8600](https://tickets.puppetlabs.com/browse/MODULES-8600)) -- Fix sqlserver_instances fact fails when registry contains uninstalled instances ([MODULES-8439](https://tickets.puppetlabs.com/browse/MODULES-8439)) -- Switch to using PowerShell `Restart-Service .. -Force` to restart the SQLServer service in `sqlserver::sp_configure` ([MODULES-6904](https://tickets.puppetlabs.com/browse/MODULES-6904)) -- Fix ERB Template Errors ([MODULES-9912](https://tickets.puppetlabs.com/browse/MODULES-9912)) - -## [2.5.0] - 2019-03-26 - -## Added - -- Bolt task to start SQL agent jobs ([MODULES-8610](https://tickets.puppetlabs.com/browse/MODULES-8610)). - -## Fixed - -- Missing type declaration for the get_sqlagent_job.json -- Make job_name param required for the start_sql_agent_job task ([MODULES-8749](https://tickets.puppetlabs.com/browse/MODULES-8749)) - -## [2.4.0] - 2019-03-12 - -### Added - -- Get agent jobs Bolt task ([MODULES-8692](https://tickets.puppetlabs.com/browse/MODULES-8692)) -- Get sql logins Bolt task ([MODULES-8606](https://tickets.puppetlabs.com/browse/MODULES-8606)) -- Set sql logins Bolt task ([MODULES-8606](https://tickets.puppetlabs.com/browse/MODULES-8606)) - -### Fixed +- (MODULES-10825) - Dotnet installation fix [#392](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/392) ([david22swan](https://github.com/david22swan)) -- Cannot manage a role with the same name on two instances or two databases ([MODULES-8677](https://tickets.puppetlabs.com/browse/MODULES-8677)) (Thanks [Dylan Ratcliffe](https://github.com/dylanratcliffe)) -- Removing a SQL Login via `ensure => absent` in a sqlserver::login resource is not idempotent. ([MODULES-8685](https://tickets.puppetlabs.com/browse/MODULES-8685)) (Thanks [Dylan Ratcliffe](https://github.com/dylanratcliffe)) +## [v3.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.0.0) - 2021-03-03 -## [2.3.0] - 2019-01-22 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.2...v3.0.0) ### Added -- Add support for installing and managing SQL 2019 instances ([MODULES-8438](https://tickets.puppetlabs.com/browse/MODULES-8438)) +- pdksync - (feat) - Add support for Puppet 7 [#363](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/363) ([daianamezdrea](https://github.com/daianamezdrea)) ### Changed - -- License terms updated to allow a Bolt trial period ([License](https://github.com/puppetlabs/puppetlabs-sqlserver/blob/main/LICENSE)) +- pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#369](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/369) ([carabasdaniel](https://github.com/carabasdaniel)) ### Fixed -- .NET 3.5 could be installed in cases where it was not necessary. ([MODULES-8438](https://tickets.puppetlabs.com/browse/MODULES-8438)) -- Features were not detected correctly if the registry keys were stored with a value other than 1. (Thanks [GrammatonKlaric](https://github.com/GrammatonKlaric)) ([MODULES-7734](https://tickets.puppetlabs.com/browse/MODULES-7734)) - -## [2.2.0] - 2018-12-3 - -### Added -- Convert module for PDK ([MODULES-7406](https://tickets.puppetlabs.com/browse/MODULES-7406)) - -### Changed -- Update support for Puppet version 6. ([MODULES-7833](https://tickets.puppetlabs.com/browse/MODULES-7833)) -- Update README_ja_JP.md -- Update stdlib version to 6. ([MODULES-7705](https://tickets.puppetlabs.com/browse/MODULES-7705)) +- (FM-8879) Handle T-SQL Errors Properly [#349](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/349) ([RandomNoun7](https://github.com/RandomNoun7)) +## [v2.6.2](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.6.2) - 2020-01-21 -## [2.1.1] - 2018-03-14 - -### Added -- Add CONTRIBUTING.md ([FM-6605](https://tickets.puppetlabs.com/browse/FM-6605)) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.1...v2.6.2) ### Fixed -- Fix problem installing sql instance when an array of SQL Admins are specified. ([MODULES-6356](https://tickets.puppetlabs.com/browse/MODULES-6356)) -- Fix AppVeyor OpenSSL bug.([Modsync commit with discussion](https://github.com/puppetlabs/modulesync_configs/commit/f04d0d1119cb5cbd4c3aac76047c4c766ae1fcb2)) -- During acceptance testing, only execute server provisioning steps if there is - a server in the hosts array. -- Stop running `gem update bundler` during Travis runs. ([MODULES-6339](https://tickets.puppetlabs.com/browse/MODULES-6339)) -- The `sqlserver_tsql` resource now returns errors from sql queries properly. ([MODULES-6281](https://tickets.puppetlabs.com/browse/MODULES-6281)) - -## [2.1.0] - 2017-12-8 - -### Added - -- Add support for installing and managing SQL 2017 instances. ([MODULES-6168](https://tickets.puppetlabs.com/browse/MODULES-6168)) - -### Changed +- (MODULES-10384) - Registry value check tightened [#343](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/343) ([david22swan](https://github.com/david22swan)) +- (MODULES-10335) - Update exec's title to be unique [#341](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/341) ([david22swan](https://github.com/david22swan)) -- Update documentation to reflect change that adds 2017 support. ([MODULES-6244](https://tickets.puppetlabs.com/browse/MODULES-6244)) +## [v2.6.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.6.1) - 2020-01-20 -## [2.0.2] - 2017-12-5 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.0...v2.6.1) ### Fixed -- Fix bug where Puppet will not detect existing sql instances properly and -attempts to reinstall an instance that already exists ([MODULES-6022](https://tickets.puppetlabs.com/browse/MODULES-6022)) - -## [2.0.1] - 2017-11-15 - -### Changed +- (MODULES-10388) fix missing gem [#339](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/339) ([sheenaajay](https://github.com/sheenaajay)) -- Allow connections over TLS 1.1+ by replacing OLEDB driver with SQL Native Client ([MODULES-5693](https://tickets.puppetlabs.com/browse/MODULES-5693)) -- Updated documentation to include 2016 as a supported version of SQL Server +## [v2.6.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.6.0) - 2019-10-22 -### Fixed - -- Ensure instances without SQL Engine are discoverable ([MODULES-5566](https://tickets.puppetlabs.com/browse/MODULES-5566)) - -## [2.0.0] - 2017-08-10 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.5.1...v2.6.0) ### Added -- Added more detailed examples to the README -- Updated with Puppet 4 data types ([MODULES-5126](https://tickets.puppet.com/browse/MODULES-5126)) -- Added parameters to manage PolyBase ([MODULES-5070](https://tickets.puppet.com/browse/MODULES-5070)) -- Added support for Windows Server 2016 -- Added test tiering and test mode switcher ([FM-5062](https://tickets.puppet.com/browse/FM-5062), [FM-6141](https://tickets.puppet.com/browse/FM-6141)) -- Make .Net installation errors more obvious ([MODULES-5092](https://tickets.puppet.com/browse/MODULES-5092)) - -### Changed +- Add support for Server 2019 [#327](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/327) ([sanfrancrisko](https://github.com/sanfrancrisko)) -- Updated metadata for Puppet 5 ([MODULES-5144](https://tickets.puppet.com/browse/MODULES-5144)) +## [v2.5.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v2.5.1) - 2019-09-20 -### Deprecated - -- Deprecated the use of `Tools` and `SQL` as installation features ([MODULES-4257](https://tickets.puppet.com/browse/MODULES-4257)) - -### Removed - -- Removed unsupported Puppet versions from metadata ([MODULES-4842](https://tickets.puppet.com/browse/MODULES-4842)) -- Removed support for Stdlib on unsupported Puppet versions, (Stdlib versions less than 4.13.0) -- Removed service_ensure parameter as it had no use ([MODULES-5030](https://tickets.puppet.com/browse/MODULES-5030)) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.5.0...v2.5.1) ### Fixed -- Using as_sysadmin_accounts without AS feature will error ([MODULES-2386](https://tickets.puppet.com/browse/MODULES-2386)) -- SNAC_SDK shared feature can not be managed by the module ([FM-5389](https://tickets.puppet.com/browse/FM-5389)) -- Purge members from SQL Server Role should actually purge ([MODULES-2543](https://tickets.puppet.com/browse/MODULES-2543)) -- Identifiers are properly escaped during database creation ([FM-5021](https://tickets.puppet.com/browse/FM-5021)) -- Removed forced TCP connection for SQL management ([MODULES-4915](https://tickets.puppet.com/browse/MODULES-4915)) - -## [1.2.0] - 2017-05-08 - -### Added - -- Added locales directory, config.yaml and POT file for i18n. ([MODULES-4334](https://tickets.puppet.com/browse/MODULES-4334)) -- Puppet-module-gems now implemented +- (MODULES-9912) ERB Template Errors [#320](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/320) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-6904) Restart SQL Server Service with Dependent Services [#315](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/315) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-8439) Fix sqlserver_instances custom fact [#314](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/314) ([carabasdaniel](https://github.com/carabasdaniel)) +- (MODULES-8600) add DQC to sqlserver_features [#313](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/313) ([tphoney](https://github.com/tphoney)) -### Fixed - -- Replace Puppet.version comparison with Puppet::Util::Package.versioncmp ([MODULES-4528](https://tickets.puppetlabs.com/browse/MODULES-4528)) -- Update beaker tests for Jenkins CI ([MODULES-4667](https://tickets.puppet.com/browse/MODULES-4667)) - - -## [1.16] - 2017-03-07 - -### Fixed +## [2.5.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.5.0) - 2019-03-26 -- Fix issue where error was raised when adding or removing features if setup.exe returned 1641 (Reboot initiated) or 3010 (Reboot required) exit codes, only a warning is raised now ([MODULES-4468](https://tickets.puppetlabs.com/browse/MODULES-4468)). - -## [1.1.5] - 2017-02-15 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.4.0...2.5.0) ### Added -- Obfuscate passwords in logs if sqlserver_instance raises an error ([MODULES-4255](https://tickets.puppet.com/browse/MODULES-4255)). +- (MODULES-8610) Add start agent job task [#301](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/301) ([RandomNoun7](https://github.com/RandomNoun7)) ### Fixed -- Fix issues with installing .Net 3.5 in acceptance tests -- Fix various issues with test environment in AppVeyor, Travis CI and Jenkins -- Fix documentation for localizationb +- (MODULES-8749) Make job_name param required. [#303](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/303) ([RandomNoun7](https://github.com/RandomNoun7)) -## [1.1.4] - 2016-08-31 +### Other -### Added +- (MAINT) Increase timeout interval [#306](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/306) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-8761) Docs release review [#305](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/305) ([clairecadman](https://github.com/clairecadman)) -- Add `windows_feature_source` parameter to the `sqlserver_instance` and `sqlserver_features` resources. This specifies the location of the Windows Feature source files, which might be needed to install the .NET Framework. See https://support.microsoft.com/en-us/kb/2734782 for more information ([MODULES-3202](https://tickets.puppet.com/browse/MODULES-3202)). +## [2.4.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.4.0) - 2019-03-12 -### Fixed +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.3.0...2.4.0) -- Fix issues when adding multiple SYSADMIN role accounts on instance creation ([MODULES-3427](https://tickets.puppet.com/browse/MODULES-3427)). -- Fix issues when creating and deleting Windows base logins ([MODULES-3256](https://tickets.puppet.com/browse/MODULES-3256)). -- Fix errors when deleting MS SQL Server logins ([MODULES-2323](https://tickets.puppet.com/browse/MODULES-2323)) and databases ([MODULES-2554](https://tickets.puppet.com/browse/MODULES-2554)). -- Refactor acceptance tests for `sqlserver::login` resource ([MODULES-3256](https://tickets.puppet.com/browse/MODULES-3256)). -- Fix issues when modifying server roles for an existing login ([MODULES-3083](https://tickets.puppet.com/browse/MODULES-3083)). -- Fix issues when modifying an existing Windows user login ([MODULES-3752](https://tickets.puppet.com/browse/MODULES-3752)). +### Other -## [1.1.3] - 2016-07-12 +- Release Prep 2.4.0 [#298](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/298) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-8721) README edit [#297](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/297) ([clairecadman](https://github.com/clairecadman)) +- (MODULES-8677) Made resource title unique among many instances [#296](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/296) ([dylanratcliffe](https://github.com/dylanratcliffe)) +- (MODULES-8685) Changed END to be in the same conditional as BEGIN [#295](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/295) ([dylanratcliffe](https://github.com/dylanratcliffe)) +- (MODULES-8692) Get Agent Jobs Task [#294](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/294) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-8606) Add SQL Logins Tasks [#291](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/291) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MAINT) Migrate test resources to artifactory - Fix Pipelines. [#290](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/290) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-8489) Mergeback to master [#289](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/289) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) -### Added +## [2.3.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.3.0) - 2019-01-22 -- Update documentation with a more advanced SQL example. -- Add Windows Based Authentication for `sqlserver::config`. Modifies the `sqlserver::config` class with an additional property called `login_type` which can be either `SQL_LOGIN` or `WINDOWS_LOGIN`, with a default of `SQL_LOGIN`. +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.2.0...2.3.0) -### Changed -- Minor refactoring of code which is not used or makes code path more obvious. +### Other -### Fixed +- (MODULES-8485) Release Prep 2.3.0 [#288](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/288) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MAINT) Fix changelog. [#287](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/287) ([RandomNoun7](https://github.com/RandomNoun7)) +- Updated license terms [#286](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/286) ([turbodog](https://github.com/turbodog)) +- (MODULES-8438) Install 2019 [#285](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/285) ([RandomNoun7](https://github.com/RandomNoun7)) +- (maint) Update pdk template [#284](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/284) ([jpogran](https://github.com/jpogran)) +- (MODULES-8130) Merge-back of release to master [#283](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/283) ([glennsarti](https://github.com/glennsarti)) +- MODULES-7734 Detect installed features with value greater than 1 [#274](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/274) ([GrammatonKlaric](https://github.com/GrammatonKlaric)) -- Fix Role Name Collisions. This fix introduces the database name into the title created for the `sqlserver_tsql` statements so that it is unique. -- Fix TSQL error propagation. Introduce a minor refactor so that the `returns` property captures errors properly from TSQL executions. -- Emit debug output on failed `onlyif` TSQL. Previously, there was no way of getting the log output from SQL Server when executing TSQL during an `onlyif`. +## [2.2.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.2.0) - 2018-12-04 -## [1.1.2] - 2016-04-11 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.1.1...2.2.0) -### Changed +### Other -- Update supported Puppet version ranges. +- Update Release Date In Changelog [#281](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/281) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MAINT) fix CHANGELOG compare link [#280](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/280) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- (MODULES-8126) release prep for 2.2.0 [#279](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/279) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- (L10n) Updating translations for readmes/README_ja_JP.md [#278](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/278) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- (MODULES-7833) Update metadata for Puppet 6 [#277](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/277) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- (maint) Spec fixes [#273](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/273) ([Iristyle](https://github.com/Iristyle)) +- pdksync - (MODULES-7658) use beaker4 in puppet-module-gems [#272](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/272) ([tphoney](https://github.com/tphoney)) +- pdksync - (MODULES-7705) - Bumping stdlib dependency from < 5.0.0 to < 6.0.0 [#271](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/271) ([pmcmaw](https://github.com/pmcmaw)) +- pdksync - (MODULES-7658) use beaker3 in puppet-module-gems [#270](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/270) ([tphoney](https://github.com/tphoney)) +- (MODULES-7406) PDK Convert the module [#269](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/269) ([glennsarti](https://github.com/glennsarti)) +- Merge Release Back To Master [#268](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/268) ([RandomNoun7](https://github.com/RandomNoun7)) -## [1.1.1] - 2015-12-08 +## [2.1.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.1.1) - 2018-03-14 -### Changed +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.1.0...2.1.1) -- Support newer PE versions. +### Other -## [1.1.0] - 2015-09-08 +- (MAINT) Fix Release Date in Changelog [#267](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/267) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MAINT) Fix Changelog Link [#266](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/266) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-6760) prep for 2.1.1 release [#265](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/265) ([RandomNoun7](https://github.com/RandomNoun7)) +- (DOCUMENT-824) Update Changelog Format [#264](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/264) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-6281) Return Errors from T-SQL [#263](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/263) ([RandomNoun7](https://github.com/RandomNoun7)) +- (FM-6605) Add CONTRIBUTING.MD to repository [#262](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/262) ([glennsarti](https://github.com/glennsarti)) +- (maint) modulesync 65530a4 Update Travis [#260](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/260) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (MODULES-6356) Fixes a problem still remaining from MODULES-2904 [#259](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/259) ([kreeuwijk](https://github.com/kreeuwijk)) +- (maint) modulesync cd884db Remove AppVeyor OpenSSL update on Ruby 2.4 [#258](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/258) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (maint) - modulesync 384f4c1 [#256](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/256) ([tphoney](https://github.com/tphoney)) +- Merge Release back to master [#255](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/255) ([jpogran](https://github.com/jpogran)) -### Added +## [2.1.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.1.0) - 2017-12-08 -- `sqlserver_instance` and `sqlserver_features` have new parameter `install_switches`, which takes a hash of install switches and writes them to a temporary configuration file for the install process. ([FM-2303](https://tickets.puppetlabs.com/browse/FM-2303)) -- Add define for permissions for Users, Roles, and Logins. -- New `sqlserver_tsql` provider available to execute custom scripts. +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.0.2...2.1.0) -### Changed +### Other -- Remove dependency on 'sqlcmd.exe'. ([FM-2577](https://tickets.puppetlabs.com/browse/FM2577)) -- `sqlserver::config` no longer writes a file to the sytem. -- Performance discovery improvements. +- (MODULES-6239) prep for 2.1.0 release [#254](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/254) ([RandomNoun7](https://github.com/RandomNoun7)) +- (MODULES-6244) Update 2017 Support [#253](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/253) ([RandomNoun7](https://github.com/RandomNoun7)) +- Merge Release back to Master [#252](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/252) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (MODULES-6168) Detect SQL 2017 [#251](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/251) ([RandomNoun7](https://github.com/RandomNoun7)) -### Removed +## [2.0.2](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.0.2) - 2017-12-04 -- Remove dependency for ACL modules. +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.0.1...2.0.2) -### Fixed +### Other + +- (MODULES-6022) Make SQLServer Instance Idempotent Again [#250](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/250) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (maint) - modulesync 1d81b6a [#248](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/248) ([pmcmaw](https://github.com/pmcmaw)) +- Merge release back into master [#247](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/247) ([glennsarti](https://github.com/glennsarti)) +- (FM-6464) Update metadata for open sourcing [#245](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/245) ([michaeltlombardi](https://github.com/michaeltlombardi)) -- Munge values for instance names to always be uppercase when comparing. -- Change the way we look up logins to use sys.server_principals instead of a function that might not report correctly. -- Fix issue with `collation_name` and databases where the variable was not named properly, causing it to never be set. +## [2.0.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.0.1) - 2017-11-14 -## [1.0.0] - 2014-12-08 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.0.0...2.0.1) -Initial release. +### Other -[Unreleased]: https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.5.1..main -[2.5.1]: https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.5.0..v2.5.1 -[2.5.0]: https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.4.0..2.5.0 -[2.4.0]: https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.3.0..2.4.0 -[2.3.0]: https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.2.0..2.3.0 -[2.2.0]: https://github.com/puppetlabs/puppetlabs-sqlserver/compare/2.1.1..2.2.0 +- (MODULES-5961) Prep for release 2.0.1 [#246](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/246) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (MAINT) Correct supported versions & platforms [#244](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/244) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (MODULES-5693) Replace SQLOLEDB with SQLNCLI11 [#243](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/243) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (maint) Remove instance during acceptance tests [#242](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/242) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5566) Rewrite Instance Discovery [#241](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/241) ([michaeltlombardi](https://github.com/michaeltlombardi)) +- (Maintenance) remove redundant rake task [#240](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/240) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- Added 2016 to supported versions [#239](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/239) ([davinhanlon](https://github.com/davinhanlon)) +- (maint) modulesync 892c4cf [#238](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/238) ([HAIL9000](https://github.com/HAIL9000)) +- release 2.0.0 mergeback [#237](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/237) ([eputnam](https://github.com/eputnam)) +## [2.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/2.0.0) - 2017-08-10 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.2.0...2.0.0) + +### Other + +- (maint) Update changelog to comply with Puppet formatting [#236](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/236) ([glennsarti](https://github.com/glennsarti)) +- (maint) modulesync 915cde70e20 [#235](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/235) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5209) Prepare for 2.0.0 release [#234](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/234) ([glennsarti](https://github.com/glennsarti)) +- (FM-6141) Add test-tiering, and README to spec directory [#233](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/233) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- some edits for sqlserver changes [#232](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/232) ([jbondpdx](https://github.com/jbondpdx)) +- (MODULES-5070) Add polybase parameters to sql_instance [#231](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/231) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5126) Use integer in acceptance test [#230](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/230) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5187)(MODULES-52080) mysnc puppet 5 and ruby 2.4 [#229](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/229) ([eputnam](https://github.com/eputnam)) +- (MODULES-5144) Prep for puppet 5 [#228](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/228) ([hunner](https://github.com/hunner)) +- (MODULES-5126) Puppet4ing SQL Server [#227](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/227) ([glennsarti](https://github.com/glennsarti)) +- (maint) Add more advanced examples to documentation [#226](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/226) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-4842) Update puppet compatibility with 4.7 as lower bound [#225](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/225) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-4915) Remove forced TCP connection for SQL management [#224](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/224) ([glennsarti](https://github.com/glennsarti)) +- (FM-5062) Add testmode switcher to sqlserver module [#223](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/223) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) +- (FM-5021) Escaping identifiers when creating a database [#222](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/222) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-2543) Purge members from SQL Server Role [#221](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/221) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-2386) Using as_sysadmin_accounts without AS feature should error [#220](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/220) ([glennsarti](https://github.com/glennsarti)) +- (FM-5389) Fix sql_features when installing SNAC_SDK [#219](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/219) ([glennsarti](https://github.com/glennsarti)) +- (FM-5389) Add missing shared feature SNAC_SDK [#218](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/218) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5030) Remove service_ensure parameter [#217](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/217) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5092) Failures during .Net 3 installation should be obvious [#216](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/216) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-4257) Modify instance and features for SQL Server 2016 [#215](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/215) ([glennsarti](https://github.com/glennsarti)) +- (maint) Update test helper for SQL Server 2016 [#213](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/213) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-5031) Modify facts for SQL Server 2016 [#212](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/212) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-4257) Add SQL Server 2016 support in acceptance tests [#211](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/211) ([glennsarti](https://github.com/glennsarti)) +- Release mergeback [#210](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/210) ([pmcmaw](https://github.com/pmcmaw)) + +## [1.2.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.2.0) - 2017-05-09 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.6...1.2.0) + +### Other + +- 1.2.0 Release Prep [#209](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/209) ([HelenCampbell](https://github.com/HelenCampbell)) +- fixing a typo for jp translation [#208](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/208) ([jbondpdx](https://github.com/jbondpdx)) +- Adding correct project url and newline to metadata [#207](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/207) ([HelenCampbell](https://github.com/HelenCampbell)) +- (MODULES-4667) Update beaker tests for Jenkins CI [#206](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/206) ([glennsarti](https://github.com/glennsarti)) +- [msync] 786266 Implement puppet-module-gems, a45803 Remove metadata.json from locales config [#205](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/205) ([wilson208](https://github.com/wilson208)) +- (MODULES-4334) - Adding locales directory, POT file and config.yaml [#204](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/204) ([pmcmaw](https://github.com/pmcmaw)) +- [MODULES-4528] Replace Puppet.version comparison with Puppet::Util::Package.versioncmp [#203](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/203) ([wilson208](https://github.com/wilson208)) +- (maint) Release mergeback [#202](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/202) ([DavidS](https://github.com/DavidS)) -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* +## [1.1.6](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.6) - 2017-03-07 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.5...1.1.6) + +### Other + +- [FM-6077] Release 1.1.6 [#201](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/201) ([wilson208](https://github.com/wilson208)) +- [PE-17491] Do not fail on install when a restart exit code is returned [#200](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/200) ([wilson208](https://github.com/wilson208)) + +## [1.1.5](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.5) - 2017-02-16 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.4...1.1.5) + +### Other + +- (FM-6026) Release 1.1.5 [#199](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/199) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-4321): edit sqlserver for loc [#198](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/198) ([jbondpdx](https://github.com/jbondpdx)) +- (maint) Prime Feature and Instance installation with .Net 3.5 source [#197](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/197) ([wilson208](https://github.com/wilson208)) +- (MODULES-4098) Sync the rest of the files [#196](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/196) ([hunner](https://github.com/hunner)) +- [MODULES-4255] Obfuscate passwords in sqlserver_instance [#195](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/195) ([wilson208](https://github.com/wilson208)) +- (MODULES-4263) add blacksmith rake tasks [#194](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/194) ([eputnam](https://github.com/eputnam)) +- (MODULES-4097) Sync travis.yml [#193](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/193) ([hunner](https://github.com/hunner)) +- (FM-5972) Update to next modulesync_configs [dedaf10] [#192](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/192) ([DavidS](https://github.com/DavidS)) +- (MODULES-3632) Use json_pure always [#191](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/191) ([hunner](https://github.com/hunner)) +- (MODULES-3704) Update gemfile template to be identical [#190](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/190) ([hunner](https://github.com/hunner)) + +## [1.1.4](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.4) - 2016-08-31 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.3...1.1.4) + +### Other + +- (FM-5476) (docs) Edits for docs signoff [#189](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/189) ([gguillotte](https://github.com/gguillotte)) +- (MODULES-3775) (msync 8d0455c) update travis/appveyer w/Ruby 2.3 [#188](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/188) ([MosesMendoza](https://github.com/MosesMendoza)) +- (maint) modulesync 70360747 [#187](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/187) ([glennsarti](https://github.com/glennsarti)) +- (FM-5473) Release 1.1.4 [#186](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/186) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-3752) Fix modifying server_roles for an existing WINDOWS_LOGIN [#185](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/185) ([glennsarti](https://github.com/glennsarti)) +- (BKR-914) Add workaround for beaker bug BKR-914 [#184](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/184) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-3202) Fix install dependencies with custom source [#183](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/183) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-3256)(MODULES-2323)(MODULES-2554)(MODULES-3083) Fix sqlserver::login resource [#182](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/182) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-3640) Update modulesync 30fc4ab [#181](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/181) ([MosesMendoza](https://github.com/MosesMendoza)) +- (PA-285) Branding name change [#166](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/166) ([jpogran](https://github.com/jpogran)) + +## [1.1.3](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.3) - 2016-07-12 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.2...1.1.3) + +### Other + +- (MODULES-3493) Prepare for Release v1.1.3 [#179](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/179) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-3536) modsync update [#177](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/177) ([glennsarti](https://github.com/glennsarti)) +- (maint) Update rakefile for puppetlabs_spec_helper [#176](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/176) ([glennsarti](https://github.com/glennsarti)) +- (FM-5387) Remove simplecov gem and update for modsync [#175](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/175) ([glennsarti](https://github.com/glennsarti)) +- (PE-16132) Add Windows Based Authentication for sqlserver::config [#174](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/174) ([glennsarti](https://github.com/glennsarti)) +- (FM-5324) Fix TSQL error propagation [#173](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/173) ([Iristyle](https://github.com/Iristyle)) +- (maint) remove trailing README whitespace [#171](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/171) ([Iristyle](https://github.com/Iristyle)) +- (MODULES-3355) Fix acceptance tests for Sqlserver role [#169](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/169) ([jpogran](https://github.com/jpogran)) +- (MODULES-3356) Branding Name Change [#168](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/168) ([jpogran](https://github.com/jpogran)) +- (MODULES-3355) Fix Role Name Collisions [#167](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/167) ([jpogran](https://github.com/jpogran)) +- Merge up to master from stable after modsync changes [#165](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/165) ([ferventcoder](https://github.com/ferventcoder)) +- (maint) modsync update - stable [#163](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/163) ([glennsarti](https://github.com/glennsarti)) +- (MODULES-3240) Fix rspec-puppet incompatibility [#162](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/162) ([glennsarti](https://github.com/glennsarti)) + +## [1.1.2](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.2) - 2016-04-08 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.1...1.1.2) + +### Other + +- (FM-5081) Supported Release 1.1.2 [#160](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/160) ([ferventcoder](https://github.com/ferventcoder)) +- (FM-5080) add Puppet version ranges [#159](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/159) ([ferventcoder](https://github.com/ferventcoder)) +- (FM-5041) Install PE License for Acceptance Testing [#158](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/158) ([cowofevil](https://github.com/cowofevil)) +- (FM-4918) update modsync / Restrict Rake ~> 10.1 [#153](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/153) ([ferventcoder](https://github.com/ferventcoder)) + +## [1.1.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.1) - 2015-12-08 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.1.0...1.1.1) + +### Other + +- (FM-3940) Fix specs - Puppet 4.x validation errors [#155](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/155) ([ferventcoder](https://github.com/ferventcoder)) +- (FM-3502) Release 1.1.1 [#154](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/154) ([ferventcoder](https://github.com/ferventcoder)) +- (FM-3706)Create database with optional compatibility breaks CI [#152](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/152) ([phongdly](https://github.com/phongdly)) +- (FM-3655) SQL Server CI acceptance issues [#151](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/151) ([phongdly](https://github.com/phongdly)) +- (MODULES-2497) SQLSERVER - Create Automated Tests for sqlserver::login [#150](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/150) ([phongdly](https://github.com/phongdly)) +- (MODULES-2496) Create Automated Tests for sqlserver::database [#149](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/149) ([phongdly](https://github.com/phongdly)) +- (MODULES-3094) Release 1.1.0 [#148](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/148) ([cyberious](https://github.com/cyberious)) +- (MODULES-2469) Create Automated Tests for sqlserver::role [#147](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/147) ([phongdly](https://github.com/phongdly)) +- (MODULES-2454)/Automated_Test_For_Database_User [#142](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/142) ([phongdly](https://github.com/phongdly)) +- Merge master to stable [#136](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/136) ([cyberious](https://github.com/cyberious)) + +## [1.1.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.1.0) - 2015-09-08 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/1.0.0...1.1.0) + +### Other + +- (MODULES-2498) Fix the check on removal [#146](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/146) ([cyberious](https://github.com/cyberious)) +- (MODULES-2498) generate random instance name in each context [#145](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/145) ([phongdly](https://github.com/phongdly)) +- (MODULES-2464) Simplify query for sp_configure check [#144](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/144) ([cyberious](https://github.com/cyberious)) +- (MODULES-2453) Create Automated Tests for sqlserver_tsql [#141](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/141) ([phongdly](https://github.com/phongdly)) +- (MODULES-2392) Automated Tests for sqlserver::config [#140](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/140) ([phongdly](https://github.com/phongdly)) +- (MODULES-2451) Fix issue with integer interpretations [#139](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/139) ([cyberious](https://github.com/cyberious)) +- (FM-3094) Prepare for release 1.1.0 [#137](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/137) ([cyberious](https://github.com/cyberious)) +- (maint) Guarantee Facter version for old Puppets / (MODULES-2452) Update Beaker Version [#135](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/135) ([ferventcoder](https://github.com/ferventcoder)) +- (MODULES-2391) Create Automated Tests For sqlserver_instance 2015-08-26 [#134](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/134) ([phongdly](https://github.com/phongdly)) +- (MODULES-2430) Fix issue parsing facts with puppet 4 [#133](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/133) ([cyberious](https://github.com/cyberious)) +- (FM-3252) CI Pipeline for sqlserver at step 7a [#132](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/132) ([phongdly](https://github.com/phongdly)) +- (MODULES-2403) Improve error handling for sqlserver_tsql [#131](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/131) ([cyberious](https://github.com/cyberious)) +- (docs) Several docs updates [#129](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/129) ([cyberious](https://github.com/cyberious)) +- (docs) MODULES-2325 update readme to reflect permissions [#128](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/128) ([cyberious](https://github.com/cyberious)) +- (DO NOT MERGE)(MODULES-2312) Use sp_executesql to execute T-SQL [#127](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/127) ([Iristyle](https://github.com/Iristyle)) +- (maint) puppetlabs_spec_helper ~>0.10.3 [#125](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/125) ([ferventcoder](https://github.com/ferventcoder)) +- (maint) replaced debian6 by centos7 master in nodesets yml files [#124](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/124) ([phongdly](https://github.com/phongdly)) +- (MODULES-2207) bin beaker-rspec to ~> 5.1 [#123](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/123) ([ferventcoder](https://github.com/ferventcoder)) +- (MODULES-2245) Fixes issue with assumption of strings [#122](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/122) ([cyberious](https://github.com/cyberious)) +- (MODULES-2207) Modulesync [#121](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/121) ([ferventcoder](https://github.com/ferventcoder)) +- (maint) Move to use Beaker-puppet_install_helper [#120](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/120) ([cyberious](https://github.com/cyberious)) +- (maint) fix future parser acceptance failures [#119](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/119) ([Iristyle](https://github.com/Iristyle)) +- (maint) remove unneeded pre-suite module installs [#118](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/118) ([Iristyle](https://github.com/Iristyle)) +- Fix Jenkins acceptance failures [#117](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/117) ([Iristyle](https://github.com/Iristyle)) +- (FM-2303, FM-2790, FM-2445) WMI / Registry impl of Discovery Report [#116](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/116) ([Iristyle](https://github.com/Iristyle)) +- (maint) remove references to beaker method step [#115](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/115) ([zreichert](https://github.com/zreichert)) +- (maint) Inject CommonProgramFiles env var [#113](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/113) ([Iristyle](https://github.com/Iristyle)) +- (FM-2791) Add database param to sqlserver_tsql [#112](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/112) ([cyberious](https://github.com/cyberious)) +- Update README per DOC-1595 [#110](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/110) ([psoloway](https://github.com/psoloway)) +- (maint) Lint and strict variables [#109](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/109) ([cyberious](https://github.com/cyberious)) +- (MAINT) remove forge host from nodesets [#108](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/108) ([zreichert](https://github.com/zreichert)) +- (maint) fix module installation [#107](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/107) ([Iristyle](https://github.com/Iristyle)) +- (FM-2713) Remove sqlserver::config file requirement [#106](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/106) ([cyberious](https://github.com/cyberious)) +- (FM-2577) Minor SQL server connection building refactorings [#105](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/105) ([Iristyle](https://github.com/Iristyle)) +- (fix) - upcase instance name so we always have a consistent pattern to how SQL Server reports back names [#104](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/104) ([cyberious](https://github.com/cyberious)) +- (fix) - Autoload property sqlserver_tsql when running from master [#100](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/100) ([cyberious](https://github.com/cyberious)) +- (FM-2577) - Change from sqlcmd.exe to win32ole connector [#99](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/99) ([cyberious](https://github.com/cyberious)) +- (maint) - Add .geppetto-rc.json to configure excludes [#98](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/98) ([cyberious](https://github.com/cyberious)) +- Fix spec tests raise_error check [#91](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/91) ([cyberious](https://github.com/cyberious)) +- Setup acceptance tests [#87](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/87) ([zreichert](https://github.com/zreichert)) +- (BKR-147) add Gemfile setting for BEAKER_VERSION for puppet... [#84](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/84) ([anodelman](https://github.com/anodelman)) +- FM-2328: document install_switches param in sqlserver [#82](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/82) ([jbondpdx](https://github.com/jbondpdx)) +- FM-2303 Add install switches needed by customer [#81](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/81) ([cyberious](https://github.com/cyberious)) +- FM-2298 and FM-2299 update Login and User to take hash of permissions [#79](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/79) ([cyberious](https://github.com/cyberious)) +- FM-2303 Add install switches to sqlserver_install and sqlserver_features [#78](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/78) ([cyberious](https://github.com/cyberious)) +- FM-2288 Role members [#77](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/77) ([cyberious](https://github.com/cyberious)) +- FM-2287 Add Role Permissions ability [#76](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/76) ([cyberious](https://github.com/cyberious)) +- Update sqlserver_validate_range to take array [#74](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/74) ([cyberious](https://github.com/cyberious)) +- (DO NOT MERGE) - Pending Readme changes for Review [#73](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/73) ([cyberious](https://github.com/cyberious)) +- FM-1556 Add ability to manage login server level permissions [#72](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/72) ([cyberious](https://github.com/cyberious)) +- FM-2236 Add with_grant_option for user permissions [#71](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/71) ([cyberious](https://github.com/cyberious)) +- FM-1898 Add sqlserver::user::permssion with GRANT, REVOKE and DENY [#70](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/70) ([cyberious](https://github.com/cyberious)) +- FM1901 Add delete user capabilities [#69](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/69) ([cyberious](https://github.com/cyberious)) +- FM-1900 Add User defined type [#68](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/68) ([cyberious](https://github.com/cyberious)) +- Fix bug with TSQL provider rework [#67](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/67) ([cyberious](https://github.com/cyberious)) +- DOC-1510: edit tsql additions [#66](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/66) ([jbondpdx](https://github.com/jbondpdx)) +- FM-2110 README Predocs for sqlserver_tsql provider [#65](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/65) ([cyberious](https://github.com/cyberious)) +- FM-2110 Prep TSQL provider ... [#64](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/64) ([cyberious](https://github.com/cyberious)) +- FM-2102 fix examples/sp_configure.pp [#63](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/63) ([cyberious](https://github.com/cyberious)) +- FM-2122: Deleted irrelevant contribution information [#62](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/62) ([jbondpdx](https://github.com/jbondpdx)) +- add geppetto-rc file to ignore examples [#61](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/61) ([justinstoller](https://github.com/justinstoller)) +- Fix metadata.json and capture back puppet module build metadata.json [#60](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/60) ([cyberious](https://github.com/cyberious)) + +## [1.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/1.0.0) - 2014-12-15 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/ef5c2854b9d6167b9db932dfb40cf2260fd5bd5c...1.0.0) diff --git a/metadata.json b/metadata.json index 85af53b6..946913a3 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "4.0.0", + "version": "4.1.0", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2012, 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From 4486e9480076b7ab11aaaa6d2830b95474847876 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Fri, 7 Jul 2023 10:40:28 +0100 Subject: [PATCH 09/43] (maint) - update trigger in ci.yml --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 815c2451..53d4b6fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,8 @@ name: "ci" on: - pull_request: - branches: - - "main" + pull_request_target: + types: [opened, synchronize, reopened] workflow_dispatch: env: From 2a503e1784fa7007cf1b1a999ddd507ad331dae4 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Mon, 17 Jul 2023 11:56:49 +0100 Subject: [PATCH 10/43] (maint) - Replace legacy facts in spec/default_facts.yml --- spec/default_facts.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/default_facts.yml b/spec/default_facts.yml index f777abfc..f3946607 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -2,7 +2,8 @@ # # Facts specified here will override the values provided by rspec-puppet-facts. --- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" From 533c65322f28096b478aa4a8e663612def0c813f Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:36:37 +0530 Subject: [PATCH 11/43] CONT-1219 : fail ci for puppetlabs members if no label --- .github/workflows/labeller.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml index 5434d3ff..aa34247a 100644 --- a/.github/workflows/labeller.yml +++ b/.github/workflows/labeller.yml @@ -1,22 +1,27 @@ -name: community-labeller +name: Labeller on: issues: types: - opened + - labeled + - unlabeled pull_request_target: types: - opened + - labeled + - unlabeled jobs: label: runs-on: ubuntu-latest steps: - - uses: puppetlabs/community-labeller@v0 + - uses: puppetlabs/community-labeller@v1.0.1 name: Label issues or pull requests with: label_name: community label_color: '5319e7' org_membership: puppetlabs - token: ${{ secrets.IAC_COMMUNITY_LABELER }} + fail_if_member: 'true' + token: ${{ secrets.IAC_COMMUNITY_LABELER }} \ No newline at end of file From 44f7bb6a3a88af5ac4a19a193dcd938544d76224 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:46:25 +0530 Subject: [PATCH 12/43] CONT-1219 : fail ci for puppetlabs members if no label --- .github/workflows/labeller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml index aa34247a..ee149bf5 100644 --- a/.github/workflows/labeller.yml +++ b/.github/workflows/labeller.yml @@ -24,4 +24,4 @@ jobs: label_color: '5319e7' org_membership: puppetlabs fail_if_member: 'true' - token: ${{ secrets.IAC_COMMUNITY_LABELER }} \ No newline at end of file + token: ${{ secrets.IAC_COMMUNITY_LABELER }} From c7c7bb35acaffd7d42287476517a1ed66f022387 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 1 Aug 2023 03:52:45 +0530 Subject: [PATCH 13/43] CAT-1208 : Fix CI to run workflow againt PR branch --- .github/workflows/ci.yml | 8 ++++++-- .github/workflows/nightly.yml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53d4b6fe..64fa4f84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,10 @@ jobs: steps: - - name: Checkout Source + - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 @@ -61,8 +63,10 @@ jobs: FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' steps: - - name: Checkout Source + - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4878d009..da63b3ab 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -21,8 +21,10 @@ jobs: steps: - - name: Checkout Source + - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} if: ${{ github.repository_owner == 'puppetlabs' }} - name: Activate Ruby 2.7 @@ -60,8 +62,10 @@ jobs: FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' steps: - - name: Checkout Source + - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Activate Ruby 2.7 uses: ruby/setup-ruby@v1 From ac6315fbe48cdbbc65d6a7b7ef2ddc6d411675c5 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:09:57 +0530 Subject: [PATCH 14/43] CAT-1208 : Fix CI to failures --- spec/acceptance/sqlserver_config_spec.rb | 7 ++++++- spec/spec_helper_acceptance_local.rb | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/sqlserver_config_spec.rb b/spec/acceptance/sqlserver_config_spec.rb index 6788563f..6bf9a8d3 100644 --- a/spec/acceptance/sqlserver_config_spec.rb +++ b/spec/acceptance/sqlserver_config_spec.rb @@ -21,9 +21,14 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present') security_mode => 'SQL', sa_pwd => 'Pupp3t1@', windows_feature_source => 'I:\\sources\\sxs', + install_switches => { + 'SkipInstallerRunCheck' => 'True', + }, } MANIFEST - apply_manifest(pp, catch_failures: true) + retry_on_error_matching(10, 5, %r{apply manifest failed}) do + apply_manifest(pp, catch_failures: true) + end end context 'Testing sqlserver::config' do diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 7d46cc36..18a9767f 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -21,6 +21,19 @@ class Helper SQL_ADMIN_PASS = 'Pupp3t1@' USER = Helper.instance.run_shell('$env:UserName').stdout.chomp +def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, error_matcher = nil) + try = 0 + begin + try += 1 + yield + rescue StandardError => e + raise unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher) + + sleep retry_wait_interval_secs + retry + end +end + RSpec.configure do |c| c.before(:suite) do Helper.instance.run_shell('puppet module install puppetlabs-mount_iso') @@ -81,7 +94,9 @@ def mount_iso(opts = {}) drive_letter => '#{drive_letter}', } MANIFEST - Helper.instance.apply_manifest(pp) + retry_on_error_matching(10, 5, %r{apply manifest failed}) do + Helper.instance.apply_manifest(pp) + end end def base_install(sql_version) @@ -152,7 +167,9 @@ def install_sqlserver(features) windows_feature_source => 'I:\\sources\\sxs', } MANIFEST - Helper.instance.apply_manifest(pp) + retry_on_error_matching(10, 5, %r{apply manifest failed}) do + Helper.instance.apply_manifest(pp) + end end def run_sql_query(opts = {}, &block) From 91b34c04d811e349811f3b234c594092616f3257 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:03:43 +0530 Subject: [PATCH 15/43] Adding retry for acceptance if fails --- .github/workflows/nightly.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index da63b3ab..9d718e3c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -112,7 +112,16 @@ jobs: - name: Run acceptance tests run: | - bundle exec rake 'litmus:acceptance:parallel' + for i in 1 2 3; do + if bundle exec rake 'litmus:acceptance:parallel'; then + break + elif [ "$i" -lt 3 ]; then + echo "Retrying acceptance tests (Attempt $i)" + else + echo "Acceptance tests failed after $i attempts." + exit 1 + fi + done - name: Remove test environment if: ${{ always() }} From 172b8a97b58b80d50b1faabca702e83f64e2c8fd Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 22 Aug 2023 19:17:53 +0530 Subject: [PATCH 16/43] (CAT-1148) Conversion of ERB to EPP --- .rubocop_todo.yml | 1 + .../sqlserver/partial_params_args.rb | 50 +++++++ manifests/database.pp | 136 +++++++++++++++++- manifests/login.pp | 42 ++++-- manifests/login/permissions.pp | 23 ++- manifests/role.pp | 66 ++++++++- manifests/role/permissions.pp | 28 +++- manifests/sp_configure.pp | 13 +- manifests/user.pp | 29 ++-- manifests/user/permissions.pp | 26 +++- spec/functions/partial_params_args_spec.rb | 29 ++++ templates/create/database.sql.epp | 106 ++++++++++++++ templates/create/database.sql.erb | 117 --------------- templates/create/login/permission.sql.epp | 15 ++ templates/create/login/permission.sql.erb | 17 --- templates/create/role.sql.epp | 10 ++ templates/create/role.sql.erb | 10 -- templates/create/role/members.sql.epp | 30 ++++ templates/create/role/members.sql.erb | 30 ---- templates/create/role/permissions.sql.epp | 14 ++ templates/create/role/permissions.sql.erb | 15 -- templates/create/sp_configure.sql.epp | 8 ++ templates/create/sp_configure.sql.erb | 8 -- templates/create/user/permission.sql.epp | 16 +++ templates/create/user/permission.sql.erb | 17 --- .../{database.sql.erb => database.sql.epp} | 6 +- templates/delete/role.sql.epp | 18 +++ templates/delete/role.sql.erb | 18 --- templates/instance_config.epp | 5 + templates/instance_config.erb | 5 - templates/query/database_exists.sql.epp | 43 ++++++ templates/query/database_exists.sql.erb | 24 ---- .../query/login/permission_exists.sql.epp | 7 + .../query/login/permission_exists.sql.erb | 8 -- ...in_exists.sql.erb => login_exists.sql.epp} | 48 +++---- templates/query/role/member_exists.sql.epp | 22 +++ templates/query/role/member_exists.sql.erb | 22 --- .../query/role/permission_exists.sql.epp | 8 ++ .../query/role/permission_exists.sql.erb | 9 -- templates/query/role_exists.sql.epp | 7 + templates/query/role_exists.sql.erb | 7 - templates/query/sp_configure.sql.epp | 3 + templates/query/sp_configure.sql.erb | 3 - .../query/user/permission_exists.sql.epp | 7 + .../query/user/permission_exists.sql.erb | 9 -- templates/query/user_exists.sql.epp | 4 + templates/query/user_exists.sql.erb | 4 - templates/restart_service.ps1.epp | 2 + templates/restart_service.ps1.erb | 2 - .../database/collation_exists.sql.epp | 1 + .../database/collation_exists.sql.erb | 1 - .../database/compatibility_exists.sql.epp | 1 + .../database/compatibility_exists.sql.erb | 1 - .../database/containment_exists.sql.epp | 1 + .../database/containment_exists.sql.erb | 1 - .../database/db_chaining_exists.sql.epp | 1 + .../database/db_chaining_exists.sql.erb | 1 - ... default_fulltext_language_exists.sql.epp} | 4 +- ...ql.erb => default_language_exists.sql.epp} | 4 +- .../database/nested_triggers_exists.sql.epp | 1 + .../database/nested_triggers_exists.sql.erb | 1 - .../transform_noise_words_exists.sql.epp | 1 + .../transform_noise_words_exists.sql.erb | 1 - .../database/trustworthy_exists.sql.epp | 1 + .../database/trustworthy_exists.sql.erb | 1 - ...b => two_digit_year_cutoff_exists.sql.epp} | 2 +- ...m_state.sql.erb => get_perm_state.sql.epp} | 2 +- .../snippets/login/permission/exists.sql.epp | 4 + .../snippets/login/permission/exists.sql.erb | 4 - .../{exists.sql.erb => exists.sql.epp} | 2 +- ...m_state.sql.erb => get_perm_state.sql.epp} | 4 +- .../role/declare_and_set_variables.sql.epp | 11 ++ .../role/declare_and_set_variables.sql.erb | 11 -- templates/snippets/role/exists.sql.epp | 3 + templates/snippets/role/exists.sql.erb | 3 - templates/snippets/role/member_exists.sql.epp | 5 + templates/snippets/role/member_exists.sql.erb | 5 - templates/snippets/role/owner_check.sql.epp | 4 + templates/snippets/role/owner_check.sql.erb | 4 - .../role/populate_purge_members.sql.epp | 11 ++ .../role/populate_purge_members.sql.erb | 11 -- .../snippets/user/permission/exists.sql.epp | 4 + .../snippets/user/permission/exists.sql.erb | 4 - ...m_state.sql.erb => get_perm_state.sql.epp} | 2 +- 84 files changed, 819 insertions(+), 446 deletions(-) create mode 100644 lib/puppet/functions/sqlserver/partial_params_args.rb create mode 100644 spec/functions/partial_params_args_spec.rb create mode 100644 templates/create/database.sql.epp delete mode 100644 templates/create/database.sql.erb create mode 100644 templates/create/login/permission.sql.epp delete mode 100644 templates/create/login/permission.sql.erb create mode 100644 templates/create/role.sql.epp delete mode 100644 templates/create/role.sql.erb create mode 100644 templates/create/role/members.sql.epp delete mode 100644 templates/create/role/members.sql.erb create mode 100644 templates/create/role/permissions.sql.epp delete mode 100644 templates/create/role/permissions.sql.erb create mode 100644 templates/create/sp_configure.sql.epp delete mode 100644 templates/create/sp_configure.sql.erb create mode 100644 templates/create/user/permission.sql.epp delete mode 100644 templates/create/user/permission.sql.erb rename templates/delete/{database.sql.erb => database.sql.epp} (71%) create mode 100644 templates/delete/role.sql.epp delete mode 100644 templates/delete/role.sql.erb create mode 100644 templates/instance_config.epp delete mode 100644 templates/instance_config.erb create mode 100644 templates/query/database_exists.sql.epp delete mode 100644 templates/query/database_exists.sql.erb create mode 100644 templates/query/login/permission_exists.sql.epp delete mode 100644 templates/query/login/permission_exists.sql.erb rename templates/query/{login_exists.sql.erb => login_exists.sql.epp} (57%) create mode 100644 templates/query/role/member_exists.sql.epp delete mode 100644 templates/query/role/member_exists.sql.erb create mode 100644 templates/query/role/permission_exists.sql.epp delete mode 100644 templates/query/role/permission_exists.sql.erb create mode 100644 templates/query/role_exists.sql.epp delete mode 100644 templates/query/role_exists.sql.erb create mode 100644 templates/query/sp_configure.sql.epp delete mode 100644 templates/query/sp_configure.sql.erb create mode 100644 templates/query/user/permission_exists.sql.epp delete mode 100644 templates/query/user/permission_exists.sql.erb create mode 100644 templates/query/user_exists.sql.epp delete mode 100644 templates/query/user_exists.sql.erb create mode 100644 templates/restart_service.ps1.epp delete mode 100644 templates/restart_service.ps1.erb create mode 100644 templates/snippets/database/collation_exists.sql.epp delete mode 100644 templates/snippets/database/collation_exists.sql.erb create mode 100644 templates/snippets/database/compatibility_exists.sql.epp delete mode 100644 templates/snippets/database/compatibility_exists.sql.erb create mode 100644 templates/snippets/database/containment_exists.sql.epp delete mode 100644 templates/snippets/database/containment_exists.sql.erb create mode 100644 templates/snippets/database/db_chaining_exists.sql.epp delete mode 100644 templates/snippets/database/db_chaining_exists.sql.erb rename templates/snippets/database/{default_fulltext_language_exists.sql.erb => default_fulltext_language_exists.sql.epp} (50%) rename templates/snippets/database/{default_language_exists.sql.erb => default_language_exists.sql.epp} (52%) create mode 100644 templates/snippets/database/nested_triggers_exists.sql.epp delete mode 100644 templates/snippets/database/nested_triggers_exists.sql.erb create mode 100644 templates/snippets/database/transform_noise_words_exists.sql.epp delete mode 100644 templates/snippets/database/transform_noise_words_exists.sql.erb create mode 100644 templates/snippets/database/trustworthy_exists.sql.epp delete mode 100644 templates/snippets/database/trustworthy_exists.sql.erb rename templates/snippets/database/{two_digit_year_cutoff_exists.sql.erb => two_digit_year_cutoff_exists.sql.epp} (52%) rename templates/snippets/login/{get_perm_state.sql.erb => get_perm_state.sql.epp} (87%) create mode 100644 templates/snippets/login/permission/exists.sql.epp delete mode 100644 templates/snippets/login/permission/exists.sql.erb rename templates/snippets/principal/permission/{exists.sql.erb => exists.sql.epp} (63%) rename templates/snippets/principal/permission/{get_perm_state.sql.erb => get_perm_state.sql.epp} (54%) create mode 100644 templates/snippets/role/declare_and_set_variables.sql.epp delete mode 100644 templates/snippets/role/declare_and_set_variables.sql.erb create mode 100644 templates/snippets/role/exists.sql.epp delete mode 100644 templates/snippets/role/exists.sql.erb create mode 100644 templates/snippets/role/member_exists.sql.epp delete mode 100644 templates/snippets/role/member_exists.sql.erb create mode 100644 templates/snippets/role/owner_check.sql.epp delete mode 100644 templates/snippets/role/owner_check.sql.erb create mode 100644 templates/snippets/role/populate_purge_members.sql.epp delete mode 100644 templates/snippets/role/populate_purge_members.sql.erb create mode 100644 templates/snippets/user/permission/exists.sql.epp delete mode 100644 templates/snippets/user/permission/exists.sql.erb rename templates/snippets/user/permission/{get_perm_state.sql.erb => get_perm_state.sql.epp} (77%) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9fbaf4aa..1ca51aea 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -144,6 +144,7 @@ RSpec/NamedSubject: - 'spec/defines/sp_configure_spec.rb' - 'spec/defines/user_spec.rb' - 'spec/unit/puppet_x/sql_connection_spec.rb' + - 'spec/functions/partial_params_args_spec.rb' # Offense count: 31 # Configuration parameters: AllowedGroups. diff --git a/lib/puppet/functions/sqlserver/partial_params_args.rb b/lib/puppet/functions/sqlserver/partial_params_args.rb new file mode 100644 index 00000000..903d4a00 --- /dev/null +++ b/lib/puppet/functions/sqlserver/partial_params_args.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +# @summary this function populates and returns the string of arguments which later gets injected in template. +# arguments that return string holds is conditional and decided by the the input given to function. + +Puppet::Functions.create_function(:'sqlserver::partial_params_args') do + # @param args contains + # Enum['ON', 'OFF'] $db_chaining + # Enum['ON', 'OFF'] $trustworthy + # String[1] $default_fulltext_language + # String[1] $default_language + # Optional[Enum['ON', 'OFF']] $nested_triggers + # Optional[Enum['ON', 'OFF']] $transform_noise_words + # Integer[1753, 9999] $two_digit_year_cutoff + # + # @return String + # Generated on the basis of provided values. + # + # Sample Input Output + # + # Input + # args = { + # db_chaining: 'OFF', + # trustworthy: 'OFF', + # default_fulltext_language: 'English', + # default_language: 'us_english', + # two_digit_year_cutoff: 2049, + # nested_triggers: 'OFF', + # } + # + # Output + # "DB_CHAINING OFF,TRUSTWORTHY OFF,DEFAULT_FULLTEXT_LANGUAGE=[English]\n,DEFAULT_LANGUAGE = [us_english]\n,NESTED_TRIGGERS = OFF,TWO_DIGIT_YEAR_CUTOFF = 2049" + + dispatch :partial_params_args do + param 'Hash', :args + return_type 'Variant[String]' + end + + def partial_params_args(args) + partial_params = [] + partial_params << "DB_CHAINING #{args['db_chaining']}" if args['db_chaining'] + partial_params << "TRUSTWORTHY #{args['trustworthy']}" if args['trustworthy'] + partial_params << "DEFAULT_FULLTEXT_LANGUAGE=[#{args['default_fulltext_language']}]\n" if args['default_fulltext_language'] + partial_params << "DEFAULT_LANGUAGE = [#{args['default_language']}]\n" if args['default_language'] + partial_params << "NESTED_TRIGGERS = #{args['nested_triggers']}" if args['nested_triggers'] + partial_params << "TRANSFORM_NOISE_WORDS = #{args['transform_noise_words']}" if args['transform_noise_words'] + partial_params << "TWO_DIGIT_YEAR_CUTOFF = #{args['two_digit_year_cutoff']}" if args['two_digit_year_cutoff'] + partial_params.join(',') + end +end diff --git a/manifests/database.pp b/manifests/database.pp index 87564176..10bee5c2 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -179,10 +179,142 @@ 'absent' => 'delete', } + $database_containment_exists_parameters = { + 'db_name' => $db_name, + 'containment' => $containment, + } + + $database_compatibility_exists_parameters = { + 'db_name' => $db_name, + 'compatibility' => $compatibility, + } + + $database_collation_exists_parameters = { + 'db_name' => $db_name, + 'collation_name' => $collation_name, + } + + $database_db_chaining_exists_parameters = { + 'db_name' => $db_name, + 'db_chaining' => $db_chaining, + } + + $database_default_fulltext_language_exists_parameters = { + 'default_fulltext_language' => $default_fulltext_language, + 'db_name' => $db_name, + } + + $database_default_language_exists_parameters = { + 'default_language' => $default_language, + 'db_name' => $db_name, + } + + $database_nested_triggers_exists_parameters = { + 'db_name' => $db_name, + 'nested_triggers' => $nested_triggers, + } + + $database_transform_noise_words_exists_parameters = { + 'db_name' => $db_name, + 'transform_noise_words' => $transform_noise_words, + } + + $database_trustworthy_exists_parameters = { + 'db_name' => $db_name, + 'trustworthy' => $trustworthy, + } + + $database_two_digit_year_cutoff_exists_parameters= { + 'db_name' => $db_name, + 'two_digit_year_cutoff' => $two_digit_year_cutoff, + } + + $partial_params_parameters = { + 'db_chaining' => $db_chaining, + 'trustworthy' => $trustworthy, + 'default_fulltext_language' => $default_fulltext_language, + 'default_language' => $default_language, + 'nested_triggers' => $nested_triggers, + 'transform_noise_words' => $transform_noise_words, + 'two_digit_year_cutoff' => $two_digit_year_cutoff, + } + + $partial_params = sqlserver::partial_params_args($partial_params_parameters) + + if $create_delete == 'create' { + $database_create_delete_parameters = { + 'db_name' => $db_name, + 'containment' => $containment, + 'filespec_name' => $filespec_name, + 'filespec_filename' => $filespec_filename, + 'filespec_size' => $filespec_size, + 'filespec_maxsize' => $filespec_maxsize, + 'filespec_filegrowth' => $filespec_filegrowth, + 'log_name' => $log_name, + 'log_filename' => $log_filename, + 'log_size' => $log_size, + 'log_maxsize' => $log_maxsize, + 'log_filegrowth' => $log_filegrowth, + 'filestream_directory_name' => $filestream_directory_name, + 'filestream_non_transacted_access' => $filestream_non_transacted_access, + 'db_chaining' => $db_chaining, + 'trustworthy' => $trustworthy, + 'default_fulltext_language' => $default_fulltext_language, + 'default_language' => $default_language, + 'nested_triggers' => $nested_triggers, + 'transform_noise_words' => $transform_noise_words, + 'two_digit_year_cutoff' => $two_digit_year_cutoff, + 'database_compatibility_exists_parameters' => $database_compatibility_exists_parameters, + 'compatibility' => $compatibility, + 'collation_name' => $collation_name, + 'database_collation_exists_parameters' => $database_collation_exists_parameters, + 'database_db_chaining_exists_parameters' => $database_db_chaining_exists_parameters, + 'database_default_fulltext_language_exists_parameters' => $database_default_fulltext_language_exists_parameters, + 'database_default_language_exists_parameters' => $database_default_language_exists_parameters, + 'database_nested_triggers_exists_parameters' => $database_nested_triggers_exists_parameters, + 'database_transform_noise_words_exists_parameters' => $database_transform_noise_words_exists_parameters, + 'database_trustworthy_exists_parameters' => $database_trustworthy_exists_parameters, + 'database_two_digit_year_cutoff_exists_parameters' => $database_two_digit_year_cutoff_exists_parameters, + 'partial_params' => $partial_params, + } + } else { + $database_create_delete_parameters = { + 'db_name' => $db_name, + } + } + + $database_check_exists_parameters = { + 'compatibility' => $database_compatibility_exists_parameters, + 'collation' => $database_collation_exists_parameters, + 'containment' => $database_containment_exists_parameters, + 'db_chaining' => $database_db_chaining_exists_parameters, + 'default_fulltext_language' => $database_default_fulltext_language_exists_parameters, + 'default_language' => $database_default_language_exists_parameters, + 'nested_triggers' => $database_nested_triggers_exists_parameters, + 'transform_noise_words' => $database_transform_noise_words_exists_parameters, + 'trustworthy' => $database_trustworthy_exists_parameters, + 'two_digit_year_cutoff' => $database_two_digit_year_cutoff_exists_parameters, + } + + $database_exists_parameters = { + 'ensure' => $ensure, + 'db_name' => $db_name, + 'collation_name' => $collation_name, + 'containment' => $containment, + 'default_fulltext_language' => $default_fulltext_language, + 'default_language' => $default_language, + 'db_chaining' => $db_chaining, + 'nested_triggers' => $nested_triggers, + 'transform_noise_words' => $transform_noise_words, + 'trustworthy' => $trustworthy, + 'two_digit_year_cutoff' => $two_digit_year_cutoff, + 'database_check_exists_parameters' => $database_check_exists_parameters, + } + sqlserver_tsql { "database-${instance}-${db_name}": instance => $instance, - command => template("sqlserver/${create_delete}/database.sql.erb"), - onlyif => template('sqlserver/query/database_exists.sql.erb'), + command => epp("sqlserver/${create_delete}/database.sql.epp", $database_create_delete_parameters), + onlyif => epp('sqlserver/query/database_exists.sql.epp', $database_exists_parameters), require => Sqlserver::Config[$instance], } } diff --git a/manifests/login.pp b/manifests/login.pp index c09abdf3..fd2f1442 100644 --- a/manifests/login.pp +++ b/manifests/login.pp @@ -76,22 +76,40 @@ 'absent' => 'delete', } - $parameters = { - 'password' => Deferred('sqlserver::password', [$password]), - 'disabled' => $disabled, - 'login_type' => $login_type, - 'login' => $login, - 'default_language' => $default_language, - 'default_database' => $default_database, - 'check_policy' => $check_policy, - 'check_expiration' => $check_expiration, - 'svrroles' => $svrroles, + if $_create_delete == 'create' { + $create_delete_login_parameters = { + 'disabled' => $disabled, + 'login' => $login, + 'password' => Deferred('sqlserver::password', [$password]), + 'check_expiration' => $check_expiration, + 'check_policy' => $check_policy, + 'default_language' => $default_language, + 'default_database' => $default_database, + 'login_type' => $login_type, + 'svrroles' => $svrroles, + } + } else { + $create_delete_login_parameters = { + 'login' => $login, + } + } + + $query_login_exists_parameters = { + 'login' => $login, + 'disabled' => $disabled, + 'check_expiration' => $check_expiration, + 'check_policy' => $check_policy, + 'login_type' => $login_type, + 'default_database' => $default_database, + 'default_language' => $default_language, + 'ensure' => $ensure, + 'svrroles' => $svrroles, } sqlserver_tsql { "login-${instance}-${login}": instance => $instance, - command => stdlib::deferrable_epp("sqlserver/${_create_delete}/login.sql.epp", $parameters), - onlyif => template('sqlserver/query/login_exists.sql.erb'), + command => stdlib::deferrable_epp("sqlserver/${_create_delete}/login.sql.epp", $create_delete_login_parameters), + onlyif => epp('sqlserver/query/login_exists.sql.epp', $query_login_exists_parameters), require => Sqlserver::Config[$instance], } diff --git a/manifests/login/permissions.pp b/manifests/login/permissions.pp index 6249a9c5..7a277476 100644 --- a/manifests/login/permissions.pp +++ b/manifests/login/permissions.pp @@ -38,10 +38,29 @@ true => '-WITH_GRANT_OPTION', default => '' } + + $create_login_permission_parameters = { + 'permissions' => $permissions, + 'with_grant_option' => $with_grant_option, + 'login' => $login, + '_state' => $_state, + } + + $login_permission_exists_parameters = { + 'login' => $login, + '_state' => $_state, + 'with_grant_option' => $with_grant_option, + } + + $query_login_permission_exists_parameters = { + 'permissions' => $permissions, + 'login_permission_exists_parameters' => $login_permission_exists_parameters, + } + sqlserver_tsql { "login-permission-${instance}-${login}-${_state}${_grant_option}": instance => $instance, - command => template('sqlserver/create/login/permission.sql.erb'), - onlyif => template('sqlserver/query/login/permission_exists.sql.erb'), + command => epp('sqlserver/create/login/permission.sql.epp', $create_login_permission_parameters), + onlyif => epp('sqlserver/query/login/permission_exists.sql.epp', $query_login_permission_exists_parameters), require => Sqlserver::Config[$instance], } } diff --git a/manifests/role.pp b/manifests/role.pp index f3967106..09768cec 100644 --- a/manifests/role.pp +++ b/manifests/role.pp @@ -63,9 +63,50 @@ # users. see MODULES-3355 $sqlserver_tsql_title = "role-${instance}-${database}-${role}" + $role_exists_parameters = { + 'ensure' => $ensure, + 'type' => $type, + 'role' => $role, + } + + $role_owner_check_parameters = { + 'type' => $type, + 'authorization' => $authorization, + 'role' => $role, + } + + $query_role_exists_parameters = { + 'database' => $database, + 'role_exists_parameters' => $role_exists_parameters, + 'type' => $type, + 'role' => $role, + 'ensure' => $ensure, + 'authorization' => $authorization, + 'role_owner_check_parameters' => $role_owner_check_parameters, + } + + if $_create_delete == 'create' { + $role_create_delete_parameters = { + 'database' => $database, + 'role_exists_parameters' => $role_exists_parameters, + 'type' => $type, + 'role' => $role, + 'authorization' => $authorization, + 'role_owner_check_parameters' => $role_owner_check_parameters, + 'query_role_exists_parameters' => $query_role_exists_parameters, + } + } else { + $role_create_delete_parameters = { + 'database' => $database, + 'type' => $type, + 'role' => $role, + 'query_role_exists_parameters' => $query_role_exists_parameters, + } + } + sqlserver_tsql { $sqlserver_tsql_title: - command => template("sqlserver/${_create_delete}/role.sql.erb"), - onlyif => template('sqlserver/query/role_exists.sql.erb'), + command => epp("sqlserver/${_create_delete}/role.sql.epp", $role_create_delete_parameters), + onlyif => epp('sqlserver/query/role_exists.sql.epp', $query_role_exists_parameters), instance => $instance, } @@ -105,10 +146,27 @@ } } + $role_members_parameters = { + 'database' => $database, + 'role' => $role, + 'members' => $members, + 'type' => $type, + 'members_purge' => $members_purge, + } + + $query_role_member_exists_parameters = { + 'database' => $database, + 'role' => $role, + 'members' => $members, + 'ensure' => $ensure, + 'members_purge' => $members_purge, + 'type' => $type, + } + if size($members) > 0 or $members_purge == true { sqlserver_tsql { "${sqlserver_tsql_title}-members": - command => template('sqlserver/create/role/members.sql.erb'), - onlyif => template('sqlserver/query/role/member_exists.sql.erb'), + command => epp('sqlserver/create/role/members.sql.epp', $role_members_parameters), + onlyif => epp('sqlserver/query/role/member_exists.sql.epp', $query_role_member_exists_parameters), instance => $instance, } } diff --git a/manifests/role/permissions.pp b/manifests/role/permissions.pp index 684e7812..3dac63bd 100644 --- a/manifests/role/permissions.pp +++ b/manifests/role/permissions.pp @@ -52,10 +52,34 @@ ## # Parameters required in template are _state, role, _upermissions, database, type, with_grant_option ## + $role_declare_and_set_variables_parameters = { + 'type' => $type, + 'role' => $role, + 'with_grant_option' => $with_grant_option, + '_state' => $_state, + } + + $create_role_permissions_parameters = { + 'database' => $database, + 'role_declare_and_set_variables_parameters' => $role_declare_and_set_variables_parameters, + 'permissions' => $permissions, + 'with_grant_option' => $with_grant_option, + 'role' => $role, + '_state' => $_state, + 'type' => $type, + } + + $query_role_permission_exists_parameters = { + 'database' => $database, + 'role_declare_and_set_variables_parameters' => $role_declare_and_set_variables_parameters, + 'permissions' => $permissions, + 'type' => $type, + } + sqlserver_tsql { "role-permissions-${role}-${_state}${_grant_option}-${instance}-${database}": instance => $instance, - command => template('sqlserver/create/role/permissions.sql.erb'), - onlyif => template('sqlserver/query/role/permission_exists.sql.erb'), + command => epp('sqlserver/create/role/permissions.sql.epp', $create_role_permissions_parameters), + onlyif => epp('sqlserver/query/role/permission_exists.sql.epp', $query_role_permission_exists_parameters), } } } diff --git a/manifests/sp_configure.pp b/manifests/sp_configure.pp index 35783333..c3707a85 100644 --- a/manifests/sp_configure.pp +++ b/manifests/sp_configure.pp @@ -44,15 +44,22 @@ Sqlserver_tsql["sp_configure-${instance}-${config_name}"] ~> Exec["restart-service-${service_name}-${config_name}"] } + $create_sp_configure_parameters = { + 'config_name' => $config_name, + 'value' => $value, + 'reconfigure' => $reconfigure, + 'with_override' => $with_override, + } + sqlserver_tsql { "sp_configure-${instance}-${config_name}": instance => $instance, - command => template('sqlserver/create/sp_configure.sql.erb'), - onlyif => template('sqlserver/query/sp_configure.sql.erb'), + command => epp('sqlserver/create/sp_configure.sql.epp', $create_sp_configure_parameters), + onlyif => epp('sqlserver/query/sp_configure.sql.epp', { 'config_name' => $config_name, 'value' => $value }), require => Sqlserver::Config[$instance], } exec { "restart-service-${service_name}-${config_name}": - command => template('sqlserver/restart_service.ps1.erb'), + command => epp('sqlserver/restart_service.ps1.epp', { 'service_name' => $service_name }), provider => powershell, logoutput => true, refreshonly => true, diff --git a/manifests/user.pp b/manifests/user.pp index 50974b0d..eb92a1c6 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -62,18 +62,31 @@ 'absent' => 'delete', } - $parameters = { - 'password' => Deferred('sqlserver::password', [$password]), - 'database' => $database, - 'user' => $user, - 'login' => $login, - 'default_schema' => $default_schema, + if $create_delete == 'create' { + $create_delete_user_parameters = { + 'database' => $database, + 'password' => Deferred('sqlserver::password', [$password]), + 'user' => $user, + 'login' => $login, + 'default_schema' => $default_schema, + } + } else { + $create_delete_user_parameters = { + 'database' => $database, + 'user' => $user, + } + } + + $query_user_exists_parameters = { + 'database' => $database, + 'ensure' => $ensure, + 'user' => $user, } sqlserver_tsql { "user-${instance}-${database}-${user}": instance => $instance, - command => stdlib::deferrable_epp("sqlserver/${create_delete}/user.sql.epp", $parameters), - onlyif => template('sqlserver/query/user_exists.sql.erb'), + command => stdlib::deferrable_epp("sqlserver/${create_delete}/user.sql.epp", $create_delete_user_parameters), + onlyif => epp('sqlserver/query/user_exists.sql.epp', $query_user_exists_parameters), require => Sqlserver::Config[$instance], } diff --git a/manifests/user/permissions.pp b/manifests/user/permissions.pp index be107b2a..620efcef 100644 --- a/manifests/user/permissions.pp +++ b/manifests/user/permissions.pp @@ -45,11 +45,33 @@ true => '-WITH_GRANT_OPTION', default => '' } + + $user_permission_exists_parameters = { + 'user' => $user, + '_state' => $_state, + 'with_grant_option' => $with_grant_option, + } + + $user_permission_parameters = { + 'database' => $database, + 'permissions' => $permissions, + 'with_grant_option' => $with_grant_option, + 'user' => $user, + '_state' => $_state, + 'user_permission_exists_parameters' => $user_permission_exists_parameters, + } + + $query_user_permission_exists_parameters = { + 'database' => $database, + 'permissions' => $permissions, + 'user_permission_exists_parameters' => $user_permission_exists_parameters, + } + sqlserver_tsql { "user-permissions-${instance}-${database}-${user}-${_state}${_grant_option}": instance => $instance, - command => template('sqlserver/create/user/permission.sql.erb'), - onlyif => template('sqlserver/query/user/permission_exists.sql.erb'), + command => epp('sqlserver/create/user/permission.sql.epp', $user_permission_parameters), + onlyif => epp('sqlserver/query/user/permission_exists.sql.epp', $query_user_permission_exists_parameters), require => Sqlserver::Config[$instance], } } diff --git a/spec/functions/partial_params_args_spec.rb b/spec/functions/partial_params_args_spec.rb new file mode 100644 index 00000000..abff3bc8 --- /dev/null +++ b/spec/functions/partial_params_args_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'sqlserver::partial_params_args' do + let(:params) do + { + db_chaining: 'OFF', + trustworthy: 'OFF', + default_fulltext_language: 'English', + default_language: 'us_english', + two_digit_year_cutoff: 2049 + } + end + + it { is_expected.to run.with_params(nil).and_raise_error(StandardError) } + + it 'contains NESTED_TRIGGERS when nested_triggers is passed' do + params[:nested_triggers] = 'OFF' + expected_results = "DB_CHAINING OFF,TRUSTWORTHY OFF,DEFAULT_FULLTEXT_LANGUAGE=[English]\n,DEFAULT_LANGUAGE = [us_english]\n,NESTED_TRIGGERS = OFF,TWO_DIGIT_YEAR_CUTOFF = 2049" + expect(subject).to run.with_params(params.transform_keys(&:to_s)).and_return(expected_results) + end + + it 'contains TRANSFORM_NOISE_WORDS when transform_noise_words is passed' do + params[:transform_noise_words] = 'ON' + expected_results = "DB_CHAINING OFF,TRUSTWORTHY OFF,DEFAULT_FULLTEXT_LANGUAGE=[English]\n,DEFAULT_LANGUAGE = [us_english]\n,TRANSFORM_NOISE_WORDS = ON,TWO_DIGIT_YEAR_CUTOFF = 2049" + expect(subject).to run.with_params(params.transform_keys(&:to_s)).and_return(expected_results) + end +end diff --git a/templates/create/database.sql.epp b/templates/create/database.sql.epp new file mode 100644 index 00000000..0a820386 --- /dev/null +++ b/templates/create/database.sql.epp @@ -0,0 +1,106 @@ +USE master +DECLARE @default_db_path as nvarchar(max), + @default_log_path as varchar(max) +SELECT @default_db_path = CONVERT(NVARCHAR(MAX),SERVERPROPERTY('instancedefaultdatapath'),0), + @default_log_path = CONVERT(NVARCHAR(MAX),SERVERPROPERTY('instancedefaultlogpath'),0) +<% $needs_comma = false %> +IF NOT EXISTS(select name FROM sys.databases WHERE name = '<%= $db_name%>') +-- CREATE SECTION +BEGIN +CREATE DATABASE [<%= $db_name %>] + CONTAINMENT = <%= $containment %> + <% if $filespec_name and $filespec_filename { -%> + ON ( + NAME = N'<%= $filespec_name %>', + FILENAME = N'<%= $filespec_filename %>' + <% if $filespec_size { %>, SIZE = <%= $filespec_size %><%} %> + <% if $filespec_maxsize { %>, MAXSIZE = <%= $filespec_maxsize %><% } %> + <% if $filespec_filegrowth { %>, FILEGROWTH = <%= $filespec_filegrowth %><% } %> + ) + <% } -%> + <% if $log_name and $log_filename { -%> + LOG ON + ( + NAME = N'<%= $log_name %>', + FILENAME = N'<%= $log_filename %>' + <% if $log_size { %>, SIZE = <%= $log_size %> <% } %> + <% if $log_maxsize { %>, MAXSIZE = <%= $log_maxsize %><% } %> + <% if $log_filegrowth { %>, FILEGROWTH = <%= $log_filegrowth %><% } %> + ) + <%- } -%> + <% if $filestream_directory_name or $filestream_non_transacted_access or $containment == 'PARTIAL' { -%> + WITH + <% if $filestream_non_transacted_access or $filestream_directory_name { -%> + $needs_comma = true + FILESTREAM ( + <% if $filestream_non_transacted_access { -%> + NON_TRANSACTED_ACCESS = <%= $filestream_non_transacted_access %> + <% if $filestream_directory_name { %>,<% } -%> + <% } -%> + <% if $filestream_directory_name { -%> + DIRECTORY_NAME = '<%= $filestream_directory_name %>' + <% } -%> + ) + <% } -%> + <% if $containment == 'PARTIAL' { -%> + <% if $needs_comma { %>,<% } -%> + <%= $partial_params %> + <%- } -%> + <%- } -%> +<%= epp('sqlserver/snippets/database/compatibility_exists.sql.epp', $database_compatibility_exists_parameters) -%> + ALTER DATABASE [<%= $db_name %>] SET COMPATIBILITY_LEVEL = <%= $compatibility %> +<%- if $collation_name { -%> +/* Alter Database collation */ +<%= epp('sqlserver/snippets/database/collation_exists.sql.epp', $database_collation_exists_parameters) -%> + ALTER DATABASE [<%= $db_name %>] COLLATE <%= $collation_name %> +<%- } -%> +END +ELSE +-- UPDATE SECTION +BEGIN +<%= epp('sqlserver/snippets/database/compatibility_exists.sql.epp', $database_compatibility_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET COMPATIBILITY_LEVEL = <%= $compatibility %> + <%- if $collation_name { -%> +<%= epp('sqlserver/snippets/database/collation_exists.sql.epp', $database_collation_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] COLLATE <%= $collation_name %> + <%- } -%> + <%- if $containment == 'PARTIAL' { %> + /* + Specifies the default language for all newly created logins. Language can be specified by providing the + local id (lcid), the language name, or the language alias. For a list of acceptable language names and aliases, see + sys.syslanguages (Transact-SQL). This option is allowable only when CONTAINMENT has been set to PARTIAL. If CONTAINMENT + is set to NONE, errors will occur. + */ + <%- if $db_chaining { -%> +<%= epp("sqlserver/snippets/database/db_chaining_exists.sql.epp", $database_db_chaining_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET DB_CHAINING <%= $db_chaining %> + <%- } -%> + <%- if $default_fulltext_language { -%> +<%= epp("sqlserver/snippets/database/default_fulltext_language_exists.sql.epp", $database_default_fulltext_language_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET DEFAULT_FULLTEXT_LANGUAGE = [<%= $default_fulltext_language %>] + <%- } -%> + <%- if $default_language { -%> +<%= epp("sqlserver/snippets/database/default_language_exists.sql.epp", $database_default_language_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET DEFAULT_LANGUAGE = [<%= $default_language %>] + <%- } -%> + <%- if $nested_triggers { -%> +<%= epp("sqlserver/snippets/database/nested_triggers_exists.sql.epp", $database_nested_triggers_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET NESTED_TRIGGERS = <%= $nested_triggers %> + <%- } -%> + <%- if $transform_noise_words { -%> +<%= epp("sqlserver/snippets/database/transform_noise_words_exists.sql.epp", $database_transform_noise_words_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET TRANSFORM_NOISE_WORDS = <%= $transform_noise_words %> + <%- } -%> + <%- if $trustworthy { -%> +<%= epp("sqlserver/snippets/database/trustworthy_exists.sql.epp", $database_trustworthy_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET TRUSTWORTHY <%= $trustworthy %> + <%- } -%> + <%- if $two_digit_year_cutoff { -%> +<%= epp("sqlserver/snippets/database/two_digit_year_cutoff_exists.sql.epp", $database_two_digit_year_cutoff_exists_parameters) %> + ALTER DATABASE [<%= $db_name %>] SET TWO_DIGIT_YEAR_CUTOFF = <%= $two_digit_year_cutoff %> + <%- } -%> + <%- } -%> +END + +IF NOT EXISTS (select * from sys.databases WHERE name = '<%= $db_name %>') + THROW 51000, 'DATABASE CREATION FAILED', 10 diff --git a/templates/create/database.sql.erb b/templates/create/database.sql.erb deleted file mode 100644 index 3ffdcbdd..00000000 --- a/templates/create/database.sql.erb +++ /dev/null @@ -1,117 +0,0 @@ -USE master -DECLARE @default_db_path as nvarchar(max), - @default_log_path as varchar(max) -SELECT @default_db_path = CONVERT(NVARCHAR(MAX),SERVERPROPERTY('instancedefaultdatapath'),0), - @default_log_path = CONVERT(NVARCHAR(MAX),SERVERPROPERTY('instancedefaultlogpath'),0) -<% needs_comma = false %> -IF NOT EXISTS(select name FROM sys.databases WHERE name = '<%= @db_name%>') --- CREATE SECTION -BEGIN -CREATE DATABASE [<%= @db_name %>] - CONTAINMENT = <%= @containment %> - <% if @filespec_name && @filespec_filename -%> - ON ( - NAME = N'<%= @filespec_name %>', - FILENAME = N'<%= @filespec_filename %>' - <% if @filespec_size %>, SIZE = <%= @filespec_size %><% end %> - <% if @filespec_maxsize %>, MAXSIZE = <%= @filespec_maxsize %><% end %> - <% if @filespec_filegrowth %>, FILEGROWTH = <%= @filespec_filegrowth %><% end %> - ) - <% end -%> - <% if @log_name && @log_filename -%> - LOG ON - ( - NAME = N'<%= @log_name %>', - FILENAME = N'<%= @log_filename %>' - <% if @log_size %>, SIZE = <%= @log_size %> <% end %> - <% if @log_maxsize %>, MAXSIZE = <%= @log_maxsize %><% end %> - <% if @log_filegrowth %>, FILEGROWTH = <%= @log_filegrowth %><% end %> - ) - <%- end -%> - <% if @filestream_directory_name || @filestream_non_transacted_access || @containment == 'PARTIAL' -%> - WITH - <% if @filestream_non_transacted_access || @filestream_directory_name - needs_comma = true - -%> - FILESTREAM ( - <% if @filestream_non_transacted_access -%> - NON_TRANSACTED_ACCESS = <%= @filestream_non_transacted_access %> - <% if @filestream_directory_name -%>,<% end -%> - <% end -%> - <% if @filestream_directory_name -%> - DIRECTORY_NAME = '<%= @filestream_directory_name %>' - <% end -%> - ) - <% end -%> - <% if @containment == 'PARTIAL' -%> - <% if needs_comma -%>,<% end %> - <% - partialParams = []; - partialParams << "DB_CHAINING #{@db_chaining}" if @db_chaining - partialParams << "TRUSTWORTHY #{@trustworthy}" if @trustworthy - partialParams << "DEFAULT_FULLTEXT_LANGUAGE=[#{@default_fulltext_language}]\n" if @default_fulltext_language - partialParams << "DEFAULT_LANGUAGE = [#{@default_language}]\n" if @default_language - partialParams << "NESTED_TRIGGERS = #{@nested_triggers}" if @nested_triggers - partialParams << "TRANSFORM_NOISE_WORDS = #{@transform_noise_words}" if @transform_noise_words - partialParams << "TWO_DIGIT_YEAR_CUTOFF = #{@two_digit_year_cutoff}" if @two_digit_year_cutoff - -%> - <%= partialParams.join(',') %> - <%- end -%> - <%- end -%> -<%= scope.function_template(['sqlserver/snippets/database/compatibility_exists.sql.erb']) -%> - ALTER DATABASE [<%= @db_name %>] SET COMPATIBILITY_LEVEL = <%= @compatibility %> -<%- if @collation_name -%> -/* Alter Database collation */ -<%= scope.function_template(['sqlserver/snippets/database/collation_exists.sql.erb']) -%> - ALTER DATABASE [<%= @db_name %>] COLLATE <%= @collation_name %> -<%- end -%> -END -ELSE --- UPDATE SECTION -BEGIN -<%= scope.function_template(['sqlserver/snippets/database/compatibility_exists.sql.erb']) %> - ALTER DATABASE [<%= @db_name %>] SET COMPATIBILITY_LEVEL = <%= @compatibility %> - <%- if @collation_name -%> -<%= scope.function_template(['sqlserver/snippets/database/collation_exists.sql.erb']) %> - ALTER DATABASE [<%= @db_name %>] COLLATE <%= @collation_name %> - <%- end -%> - <%- if @containment == 'PARTIAL' %> - /* - Specifies the default language for all newly created logins. Language can be specified by providing the - local id (lcid), the language name, or the language alias. For a list of acceptable language names and aliases, see - sys.syslanguages (Transact-SQL). This option is allowable only when CONTAINMENT has been set to PARTIAL. If CONTAINMENT - is set to NONE, errors will occur. - */ - <%- if @db_chaining -%> -<%= scope.function_template(["sqlserver/snippets/database/db_chaining_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET DB_CHAINING <%= @db_chaining %> - <%- end -%> - <%- if @default_fulltext_language -%> -<%= scope.function_template(["sqlserver/snippets/database/default_fulltext_language_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET DEFAULT_FULLTEXT_LANGUAGE = [<%= @default_fulltext_language %>] - <%- end -%> - <%- if @default_language -%> -<%= scope.function_template(["sqlserver/snippets/database/default_language_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET DEFAULT_LANGUAGE = [<%= @default_language %>] - <%- end -%> - <%- if @nested_triggers -%> -<%= scope.function_template(["sqlserver/snippets/database/nested_triggers_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET NESTED_TRIGGERS = <%= @nested_triggers %> - <%- end -%> - <%- if @transform_noise_words -%> -<%= scope.function_template(["sqlserver/snippets/database/transform_noise_words_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET TRANSFORM_NOISE_WORDS = <%= @transform_noise_words %> - <%- end -%> - <%- if @trustworthy -%> -<%= scope.function_template(["sqlserver/snippets/database/trustworthy_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET TRUSTWORTHY <%= @trustworthy %> - <%- end -%> - <%- if @two_digit_year_cutoff -%> -<%= scope.function_template(["sqlserver/snippets/database/two_digit_year_cutoff_exists.sql.erb"]) %> - ALTER DATABASE [<%= @db_name %>] SET TWO_DIGIT_YEAR_CUTOFF = <%= @two_digit_year_cutoff %> - <%- end -%> - <%- end -%> -END - -IF NOT EXISTS (select * from sys.databases WHERE name = '<%= @db_name %>') - THROW 51000, 'DATABASE CREATION FAILED', 10 diff --git a/templates/create/login/permission.sql.epp b/templates/create/login/permission.sql.epp new file mode 100644 index 00000000..f2f3feb6 --- /dev/null +++ b/templates/create/login/permission.sql.epp @@ -0,0 +1,15 @@ +USE [master]; +DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); +<% $permissions.each |$requested_permission| { %> + <% $permission = $requested_permission.upcase %> +BEGIN + <% if $with_grant_option == false { %> + IF 'GRANT_WITH_GRANT_OPTION' = <%= epp('sqlserver/snippets/login/get_perm_state.sql.epp', { 'login' => $login }) %> + REVOKE GRANT OPTION FOR <%= $permission %> TO [<%= $login %>] CASCADE; + <% } %> + <%= $_state %> <%= $permission %> TO [<%= $login %>]<% if $with_grant_option == true { %> WITH GRANT OPTION<% } %>; +END +BEGIN + <%= epp('sqlserver/snippets/login/permission/exists.sql.epp', { 'login' => $login, '_state' => $_state, 'with_grant_option' => $with_grant_option}) %> +END +<% } %> diff --git a/templates/create/login/permission.sql.erb b/templates/create/login/permission.sql.erb deleted file mode 100644 index 80c878b3..00000000 --- a/templates/create/login/permission.sql.erb +++ /dev/null @@ -1,17 +0,0 @@ -USE [master]; -DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); -<% @permissions.each do |requested_permission| - permission = requested_permission.upcase -%> -SET @permission = '<%= permission %>' -BEGIN - <% if @with_grant_option == false %> - IF 'GRANT_WITH_GRANT_OPTION' = <%= scope.function_template(['sqlserver/snippets/login/get_perm_state.sql.erb']) %> - REVOKE GRANT OPTION FOR <%= permission %> TO [<%= @login %>] CASCADE; - <% end %> - <%= @_state %> <%= permission %> TO [<%= @login %>]<% if @with_grant_option == true %> WITH GRANT OPTION<% end %>; -END -BEGIN - <%= scope.function_template(['sqlserver/snippets/login/permission/exists.sql.erb']) %> -END -<% end %> diff --git a/templates/create/role.sql.epp b/templates/create/role.sql.epp new file mode 100644 index 00000000..bfba8298 --- /dev/null +++ b/templates/create/role.sql.epp @@ -0,0 +1,10 @@ +USE [<%= $database %>]; +BEGIN + <%= epp('sqlserver/snippets/role/exists.sql.epp', $role_exists_parameters) %> + CREATE <% if $type == 'SERVER' { %>SERVER <% } %>ROLE [<%= $role %>]<% if $authorization { %> AUTHORIZATION [<%= $authorization %>]<% } %>; + <% if $authorization { %> + <%= epp('sqlserver/snippets/role/owner_check.sql.epp', $role_owner_check_parameters) %> + ALTER AUTHORIZATION ON <% if $type =='SERVER' { %>SERVER <% } %>ROLE::[<%= $role %>] TO [<%= $authorization %>]; + <% } %> +END +<%= epp('sqlserver/query/role_exists.sql.epp', $query_role_exists_parameters) %> diff --git a/templates/create/role.sql.erb b/templates/create/role.sql.erb deleted file mode 100644 index 57441b2a..00000000 --- a/templates/create/role.sql.erb +++ /dev/null @@ -1,10 +0,0 @@ -USE [<%= @database %>]; -BEGIN - <%= scope.function_template(['sqlserver/snippets/role/exists.sql.erb']) %> - CREATE <% if @type == 'SERVER' %>SERVER <% end %>ROLE [<%= @role %>]<% if @authorization %> AUTHORIZATION [<%= @authorization %>]<% end %>; - <% if @authorization %> - <%= scope.function_template(['sqlserver/snippets/role/owner_check.sql.erb']) %> - ALTER AUTHORIZATION ON <% if @type =='SERVER' %>SERVER <% end %>ROLE::[<%= @role %>] TO [<%= @authorization %>]; - <% end %> -END -<%= scope.function_template(['sqlserver/query/role_exists.sql.erb']) %> diff --git a/templates/create/role/members.sql.epp b/templates/create/role/members.sql.epp new file mode 100644 index 00000000..8a3abe16 --- /dev/null +++ b/templates/create/role/members.sql.epp @@ -0,0 +1,30 @@ +USE [<%= $database %>]; +DECLARE + @role varchar(128) = '<%= $role %>', + @member varchar(128), + @error_msg varchar(250); + +<%- $members.each |$member| { -%> +BEGIN +SET @member = '<%= $member %>'; +<%= epp('sqlserver/snippets/role/member_exists.sql.epp', { 'type' => $type }) -%> + ALTER <% if $type == 'SERVER' { %>SERVER <% } %>ROLE [<%= $role %>] ADD MEMBER [<%= $member %>]; + +<%= epp('sqlserver/snippets/role/member_exists.sql.epp', { 'type' => $type }) -%> + THROW 51000, 'Failed to add member [<%= $member %>] to Role [<%= $role %>]', 10 +END +<% } -%> + +<% if $members_purge { %> +<%= epp('sqlserver/snippets/role/populate_purge_members.sql.epp', { 'type' => $type, 'role' => $role, 'members' => $members }) -%> + +DECLARE @sql varchar(250), @row int = 1, @row_count int; +SET @row_count = (SELECT COUNT(*) FROM @purge_members); + +WHILE(@row <= @row_count) +BEGIN + SET @sql = 'ALTER <% if $type == 'SERVER' { %>SERVER <% } %>ROLE [<%= $role %>] DROP MEMBER [' + (SELECT member FROM @purge_members WHERE ID = @row) + '];' + EXEC(@sql) + SET @row += 1 +END +<% } %> diff --git a/templates/create/role/members.sql.erb b/templates/create/role/members.sql.erb deleted file mode 100644 index b05e4009..00000000 --- a/templates/create/role/members.sql.erb +++ /dev/null @@ -1,30 +0,0 @@ -USE [<%= @database %>]; -DECLARE - @role varchar(128) = '<%= @role %>', - @member varchar(128), - @error_msg varchar(250); - -<%- @members.each do |member| -%> -BEGIN -SET @member = '<%= member %>'; -<%= scope.function_template(['sqlserver/snippets/role/member_exists.sql.erb']) -%> - ALTER <% if @type == 'SERVER' %>SERVER <% end %>ROLE [<%= @role %>] ADD MEMBER [<%= member %>]; - -<%= scope.function_template(['sqlserver/snippets/role/member_exists.sql.erb']) -%> - THROW 51000, 'Failed to add member [<%= member %>] to Role [<%= @role %>]', 10 -END -<% end -%> - -<% if @members_purge %> -<%= scope.function_template(['sqlserver/snippets/role/populate_purge_members.sql.erb']) -%> - -DECLARE @sql varchar(250), @row int = 1, @row_count int; -SET @row_count = (SELECT COUNT(*) FROM @purge_members); - -WHILE(@row <= @row_count) -BEGIN - SET @sql = 'ALTER <% if @type == 'SERVER' %>SERVER <% end %>ROLE [<%= @role %>] DROP MEMBER [' + (SELECT member FROM @purge_members WHERE ID = @row) + '];' - EXEC(@sql) - SET @row += 1 -END -<% end %> diff --git a/templates/create/role/permissions.sql.epp b/templates/create/role/permissions.sql.epp new file mode 100644 index 00000000..77f0b15e --- /dev/null +++ b/templates/create/role/permissions.sql.epp @@ -0,0 +1,14 @@ +USE [<%= $database %>]; +<%= epp('sqlserver/snippets/role/declare_and_set_variables.sql.epp', $role_declare_and_set_variables_parameters) -%> + +<% $permissions.each |$requested_permission| { %> + <% $permission = $requested_permission.upcase %> +SET @permission = '<%= $permission %>'; +<% if $with_grant_option == false { %> + IF 'GRANT_WITH_GRANT_OPTION' = <%= epp('sqlserver/snippets/principal/permission/get_perm_state.sql.epp', { 'type' => $type }) -%> + BEGIN + REVOKE GRANT OPTION FOR <%= $permission %> TO [<%= $role %>] CASCADE; + END + <% } -%> + <%= $_state %> <%= $permission %> TO [<%= $role %>]<% if $with_grant_option == true { %> WITH GRANT OPTION<% } %>; +<% } %> diff --git a/templates/create/role/permissions.sql.erb b/templates/create/role/permissions.sql.erb deleted file mode 100644 index ef7582fa..00000000 --- a/templates/create/role/permissions.sql.erb +++ /dev/null @@ -1,15 +0,0 @@ -USE [<%= @database %>]; -<%= scope.function_template(['sqlserver/snippets/role/declare_and_set_variables.sql.erb']) -%> - -<% @permissions.each do |requested_permission| - permission = requested_permission.upcase -%> -SET @permission = '<%= permission %>'; -<% if @with_grant_option == false %> - IF 'GRANT_WITH_GRANT_OPTION' = <%= scope.function_template(['sqlserver/snippets/principal/permission/get_perm_state.sql.erb']) -%> - BEGIN - REVOKE GRANT OPTION FOR <%= permission %> TO [<%= @role %>] CASCADE; - END - <% end -%> - <%= @_state %> <%= permission %> TO [<%= @role %>]<% if @with_grant_option == true %> WITH GRANT OPTION<% end %>; -<% end %> diff --git a/templates/create/sp_configure.sql.epp b/templates/create/sp_configure.sql.epp new file mode 100644 index 00000000..b6424517 --- /dev/null +++ b/templates/create/sp_configure.sql.epp @@ -0,0 +1,8 @@ +DECLARE @return_value INT +EXECUTE @return_value = sp_configure @configname = N'<%= $config_name %>', @configvalue = <%= $value %> +IF @return_value != 0 + THROW 51000,'Unable to update `<%= $config_name %>`', 10 +<% if $reconfigure { -%> +ELSE + RECONFIGURE <% if $with_override { %>WITH OVERRIDE<% } %> +<% } -%> diff --git a/templates/create/sp_configure.sql.erb b/templates/create/sp_configure.sql.erb deleted file mode 100644 index 496b4ba1..00000000 --- a/templates/create/sp_configure.sql.erb +++ /dev/null @@ -1,8 +0,0 @@ -DECLARE @return_value INT -EXECUTE @return_value = sp_configure @configname = N'<%= @config_name %>', @configvalue = <%= @value %> -IF @return_value != 0 - THROW 51000,'Unable to update `<%= @config_name %>`', 10 -<% if @reconfigure -%> -ELSE - RECONFIGURE <% if @with_override %>WITH OVERRIDE<% end %> -<% end -%> diff --git a/templates/create/user/permission.sql.epp b/templates/create/user/permission.sql.epp new file mode 100644 index 00000000..d097e276 --- /dev/null +++ b/templates/create/user/permission.sql.epp @@ -0,0 +1,16 @@ +USE [<%= $database %>]; +DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); +<% $permissions.each |$requested_permission| { %> + <% $permission = $requested_permission.upcase %> +SET @permission = '<%= $permission %>'; +BEGIN + <% if $with_grant_option == false { %> + IF 'GRANT_WITH_GRANT_OPTION' = <%= epp('sqlserver/snippets/user/permission/get_perm_state.sql.epp', { 'user' => $user }) %> + REVOKE GRANT OPTION FOR <%= $permission %> TO [<%= $user %>] CASCADE; + <% } %> + <%= $_state %> <%= $permission %> TO [<%= $user %>]<% if $with_grant_option == true { %> WITH GRANT OPTION<% } %>; +END +BEGIN + <%= epp('sqlserver/snippets/user/permission/exists.sql.epp', $user_permission_exists_parameters) %> +END +<% } %> diff --git a/templates/create/user/permission.sql.erb b/templates/create/user/permission.sql.erb deleted file mode 100644 index 641da46e..00000000 --- a/templates/create/user/permission.sql.erb +++ /dev/null @@ -1,17 +0,0 @@ -USE [<%= @database %>]; -DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); -<% @permissions.each do |requested_permission| - permission = requested_permission.upcase -%> -SET @permission = '<%= permission %>' -BEGIN - <% if @with_grant_option == false %> - IF 'GRANT_WITH_GRANT_OPTION' = <%= scope.function_template(['sqlserver/snippets/user/permission/get_perm_state.sql.erb']) %> - REVOKE GRANT OPTION FOR <%= permission %> TO [<%= @user %>] CASCADE; - <% end %> - <%= @_state %> <%= permission %> TO [<%= @user %>]<% if @with_grant_option == true %> WITH GRANT OPTION<% end %>; -END -BEGIN - <%= scope.function_template(['sqlserver/snippets/user/permission/exists.sql.erb']) %> -END -<% end %> diff --git a/templates/delete/database.sql.erb b/templates/delete/database.sql.epp similarity index 71% rename from templates/delete/database.sql.erb rename to templates/delete/database.sql.epp index 37d2c6ed..56639322 100644 --- a/templates/delete/database.sql.erb +++ b/templates/delete/database.sql.epp @@ -1,11 +1,11 @@ USE [master]; /* Delete Database Backup and Restore History from MSDB System Database */ -EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'<%= @db_name %>'; +EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'<%= $db_name %>'; /* Query to Get Exclusive Access of SQL Server Database before Dropping the Database */ -ALTER DATABASE [<%= @db_name %>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; +ALTER DATABASE [<%= $db_name %>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; /* Query to Drop Database in SQL Server */ -DROP DATABASE [<%= @db_name %>]; +DROP DATABASE [<%= $db_name %>]; diff --git a/templates/delete/role.sql.epp b/templates/delete/role.sql.epp new file mode 100644 index 00000000..a0bf04c6 --- /dev/null +++ b/templates/delete/role.sql.epp @@ -0,0 +1,18 @@ +USE [<%= $database %>]; +BEGIN + DECLARE @cmd AS NVARCHAR(MAX) = N''; + + SELECT @cmd = @cmd + ' + ALTER <% if $type == 'SERVER' { %>SERVER <% } %>ROLE [<%= $role %>] DROP MEMBER ' + QUOTENAME(members.[name]) + ';' + FROM sys.<%= $type.downcase %>_role_members AS rolemembers + JOIN sys.<%= $type.downcase %>_principals AS roles + ON roles.[principal_id] = rolemembers.[role_principal_id] + JOIN sys.<%= $type.downcase %>_principals AS members + ON members.[principal_id] = rolemembers.[member_principal_id] + WHERE roles.name = '<%= $role %>' + + EXEC(@cmd); + + DROP <% if $type == 'SERVER' { %>SERVER <% } %>ROLE [<%= $role %>]; +END +<%= epp('sqlserver/query/role_exists.sql.epp', $query_role_exists_parameters) %> diff --git a/templates/delete/role.sql.erb b/templates/delete/role.sql.erb deleted file mode 100644 index 1352aa7e..00000000 --- a/templates/delete/role.sql.erb +++ /dev/null @@ -1,18 +0,0 @@ -USE [<%= @database %>]; -BEGIN - DECLARE @cmd AS NVARCHAR(MAX) = N''; - - SELECT @cmd = @cmd + ' - ALTER <% if @type == 'SERVER' %>SERVER <% end %>ROLE [<%= @role %>] DROP MEMBER ' + QUOTENAME(members.[name]) + ';' - FROM sys.<%= @type.downcase %>_role_members AS rolemembers - JOIN sys.<%= @type.downcase %>_principals AS roles - ON roles.[principal_id] = rolemembers.[role_principal_id] - JOIN sys.<%= @type.downcase %>_principals AS members - ON members.[principal_id] = rolemembers.[member_principal_id] - WHERE roles.name = '<%= @role %>' - - EXEC(@cmd); - - DROP <% if @type == 'SERVER' %>SERVER <% end %>ROLE [<%= @role %>]; -END -<%= scope.function_template(['sqlserver/query/role_exists.sql.erb']) %> diff --git a/templates/instance_config.epp b/templates/instance_config.epp new file mode 100644 index 00000000..e0259b1e --- /dev/null +++ b/templates/instance_config.epp @@ -0,0 +1,5 @@ +<% if $admin_login_type == 'SQL_LOGIN' { %> +{ "instance": "<%= $_instance %>","admin":"<%= $admin_user %>","pass":"<%= $admin_pass %>" } +<% }else { %> +{ "instance": "<%= $_instance %>","admin":"","pass":"" } +<% } %> diff --git a/templates/instance_config.erb b/templates/instance_config.erb deleted file mode 100644 index 9b9f75ad..00000000 --- a/templates/instance_config.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%- if @admin_login_type == 'SQL_LOGIN' %> -{ "instance": "<%= @_instance %>","admin":"<%= @admin_user %>","pass":"<%= @admin_pass %>" } -<%- else %> -{ "instance": "<%= @_instance %>","admin":"","pass":"" } -<%- end %> diff --git a/templates/query/database_exists.sql.epp b/templates/query/database_exists.sql.epp new file mode 100644 index 00000000..bc68c8fe --- /dev/null +++ b/templates/query/database_exists.sql.epp @@ -0,0 +1,43 @@ +-- QUICK CHECK before most costly query +IF <% if $ensure == 'present' { %>NOT<% } %> EXISTS(SELECT name from sys.databases WHERE name = '<%= $db_name %>') + THROW 51000, 'The database does <% if $ensure == 'present' { %>not<% } %> exist', 10 +<% if $ensure == 'present' { %> + <%= epp("sqlserver/snippets/database/containment_exists.sql.epp", $database_check_exists_parameters['containment']) %> + THROW 51000, 'Database property containment not in correct state', 10 + <%= epp("sqlserver/snippets/database/compatibility_exists.sql.epp", $database_check_exists_parameters['compatibility']) %> + THROW 51000, 'Database property compatibility not in correct state', 10 + <% if $collation_name { %> + <%= epp("sqlserver/snippets/database/collation_exists.sql.epp", $database_check_exists_parameters['collation']) %> + THROW 51000, 'Database property collation not in correct state', 10 + <% } %> + <% if $containment == 'PARTIAL' { %> + <% if $default_fulltext_language { %> + <%= epp("sqlserver/snippets/database/default_fulltext_language_exists.sql.epp", $database_check_exists_parameters['default_fulltext_language']) %> + THROW 51000, 'Database property default_fulltext_language not in correct state', 10 + <% } %> + <% if $default_language { %> + <%= epp("sqlserver/snippets/database/default_language_exists.sql.epp", $database_check_exists_parameters['default_language']) %> + THROW 51000, 'Database property default_language not in correct state', 10 + <% } %> + <% if $db_chaining { %> + <%= epp("sqlserver/snippets/database/db_chaining_exists.sql.epp", $database_check_exists_parameters['db_chaining']) %> + THROW 51000, 'Database property db_chaining not in correct state', 10 + <% } %> + <% if $nested_triggers { %> + <%= epp("sqlserver/snippets/database/nested_triggers_exists.sql.epp", $database_check_exists_parameters['nested_triggers']) %> + THROW 51000, 'Database property nested_triggers not in correct state', 10 + <% } %> + <% if $transform_noise_words { %> + <%= epp("sqlserver/snippets/database/transform_noise_words_exists.sql.epp", $database_check_exists_parameters['transform_noise_words']) %> + THROW 51000, 'Database property transform_noise_words not in correct state', 10 + <% } %> + <% if $trustworthy { %> + <%= epp("sqlserver/snippets/database/trustworthy_exists.sql.epp", $database_check_exists_parameters['trustworthy']) %> + THROW 51000, 'Database property trustworthy not in correct state', 10 + <% } %> + <% if $two_digit_year_cutoff { %> + <%= epp("sqlserver/snippets/database/two_digit_year_cutoff_exists.sql.epp", $database_check_exists_parameters['two_digit_year_cutoff']) %> + THROW 51000, 'Database property two_digit_year_cutoff not in correct state', 10 + <% } %> + <% } %> +<% } %> diff --git a/templates/query/database_exists.sql.erb b/templates/query/database_exists.sql.erb deleted file mode 100644 index 640dbe2d..00000000 --- a/templates/query/database_exists.sql.erb +++ /dev/null @@ -1,24 +0,0 @@ --- QUICK CHECK before most costly query -IF <% if @ensure == 'present' %>NOT<% end %> EXISTS(SELECT name from sys.databases WHERE name = '<%= @db_name %>') - THROW 51000, 'The database does <% if @ensure == 'present' %>not<% end %> exist', 10 -<% if @ensure == 'present' - checkTemplates = [] - checkTemplates << 'containment' - checkTemplates << 'compatibility' - checkTemplates << 'collation' if @collation_name %> -<% if @containment == 'PARTIAL' - checkTemplates << 'default_fulltext_language' if @default_fulltext_language - checkTemplates << 'default_language' if @default_language - checkTemplates << 'db_chaining' if @db_chaining - checkTemplates << 'nested_triggers' if @nested_triggers - checkTemplates << 'transform_noise_words' if @transform_noise_words - checkTemplates << 'trustworthy' if @trustworthy - checkTemplates << 'two_digit_year_cutoff' if @two_digit_year_cutoff - end -%> -<%-checkTemplates.each do |check| -%> -<%= scope.function_template(["sqlserver/snippets/database/#{check}_exists.sql.erb"]) %> - THROW 51000, 'Database property <%= check %> not in correct state', 10 -<%- end -%> -<% end - #end ensure present section - -%> diff --git a/templates/query/login/permission_exists.sql.epp b/templates/query/login/permission_exists.sql.epp new file mode 100644 index 00000000..b67d7047 --- /dev/null +++ b/templates/query/login/permission_exists.sql.epp @@ -0,0 +1,7 @@ +USE [master]; +DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); +<% $permissions.each |$requested_permission| { -%> + <% $permission = $requested_permission.upcase %> +SET @permission = '<%= $permission %>' +<%= epp('sqlserver/snippets/login/permission/exists.sql.epp', $login_permission_exists_parameters) %> +<% } %> diff --git a/templates/query/login/permission_exists.sql.erb b/templates/query/login/permission_exists.sql.erb deleted file mode 100644 index d45bd27e..00000000 --- a/templates/query/login/permission_exists.sql.erb +++ /dev/null @@ -1,8 +0,0 @@ -USE [master]; -DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); -<% @permissions.each do |requested_permission| - permission = requested_permission.upcase -%> -SET @permission = '<%= permission %>' -<%= scope.function_template(['sqlserver/snippets/login/permission/exists.sql.erb']) %> -<% end %> diff --git a/templates/query/login_exists.sql.erb b/templates/query/login_exists.sql.epp similarity index 57% rename from templates/query/login_exists.sql.erb rename to templates/query/login_exists.sql.epp index 95e0560e..e3598d0b 100644 --- a/templates/query/login_exists.sql.erb +++ b/templates/query/login_exists.sql.epp @@ -1,18 +1,18 @@ DECLARE - @login as varchar(255) = '<%= @login %>', - @is_disabled as tinyint = <%= @disabled ? 1 : 0 %>, - @connect_sql_perm as char(1) = '<%= @disabled ? 'D' : 'G' %>', - @check_expiration as tinyint = <%= @check_expiration ? 1 : 0 %>, - @check_policy as tinyint = <%= @check_policy ? 1 : 0 %>, - @type_desc as varchar(50) = '<%= @login_type %>', - @default_db as varchar(255) = '<%= @default_database %>', - @default_lang as varchar(50) = '<%= @default_language %>', + @login as varchar(255) = '<%= $login %>', + @is_disabled as tinyint = <% if $disabled { %><%=1%><% }else { %><%=0%><% } %>, + @connect_sql_perm as char(1) = '<% if $disabled { %><%='D'%><% }else { %><%='G'%><% } %>', + @check_expiration as tinyint = <% if $check_expiration { %><%=1%><% }else { %><%=0%><% } %>, + @check_policy as tinyint = <% if $check_policy { %><%=1%><% }else { %><%=0%><% } %>, + @type_desc as varchar(50) = '<%= $login_type %>', + @default_db as varchar(255) = '<%= $default_database %>', + @default_lang as varchar(50) = '<%= $default_language %>', @principal_type as varchar(255) = NULL; -IF <% if @ensure == 'present' %>NOT<% end %> EXISTS(SELECT name FROM sys.server_principals WHERE name = '<%= @login %>') - THROW 51000, 'ERROR: The login is not <%= @ensure %>', 10 +IF <% if $ensure == 'present' { %>NOT<% } %> EXISTS(SELECT name FROM sys.server_principals WHERE name = '<%= $login %>') + THROW 51000, 'ERROR: The login is not <%= $ensure %>', 10 -<% if @ensure == 'present' %> +<% if $ensure == 'present' { %> BEGIN /* Check if account exists in the correct state */ SET @principal_type = (SELECT p.[type] FROM sys.server_principals p @@ -23,19 +23,19 @@ SET @principal_type = (SELECT p.[type] FROM sys.server_principals p AND p.default_language_name = @default_lang -- Only check disabled status if it's not a WINDOWS_GROUP AND (p.type_desc = 'WINDOWS_GROUP' OR p.is_disabled = @is_disabled) - <% if @login_type == 'SQL_LOGIN' %> + <% if $login_type == 'SQL_LOGIN' { %> AND s.is_policy_checked = @check_policy AND s.is_expiration_checked = @check_expiration - <% end %> - <% if @login_type == 'WINDOWS_LOGIN' %> + <% } %> + <% if $login_type == 'WINDOWS_LOGIN' { %> AND ((p.type_desc = 'WINDOWS_LOGIN') OR (p.type_desc = 'WINDOWS_GROUP')) - <% else %> + <% }else { %> AND p.type_desc = @type_desc - <% end %> + <% } %> ) IF (@principal_type IS NULL) THROW 51000, 'ERROR: The login is not in the correct state', 10 -<% if @login_type == 'WINDOWS_LOGIN' %> +<% if $login_type == 'WINDOWS_LOGIN' { %> /* Look for the CONNECT SQL server permission on the WINDOWS_GROUP */ IF (@principal_type = 'G') BEGIN @@ -48,19 +48,19 @@ BEGIN AND sp.state = @connect_sql_perm ) THROW 51000, 'ERROR: The group login is not in the correct state', 10 END -<% end %> +<% } %> /* If it does exist check for each role is in the correct state */ -<% @svrroles.each do |role, enable_bit| %> +<% $svrroles.each |$role, $enable_bit| { %> IF (SELECT COUNT(me.role_principal_id) from sys.server_role_members me JOIN sys.server_principals rol ON me.role_principal_id = rol.principal_id JOIN sys.server_principals pri ON me.member_principal_id = pri.principal_id WHERE rol.type_desc = 'SERVER_ROLE' - AND rol.name = '<%= role %>' - AND pri.name = '<%= @login %>') != <%= enable_bit %> - THROW 51000, 'ERROR: a role is not correct for <%= role %>', 10 -<% end %> + AND rol.name = '<%= $role %>' + AND pri.name = '<%= $login %>') != <%= $enable_bit %> + THROW 51000, 'ERROR: a role is not correct for <%= $role %>', 10 +<% } %> END -<% end %> +<% } %> diff --git a/templates/query/role/member_exists.sql.epp b/templates/query/role/member_exists.sql.epp new file mode 100644 index 00000000..4c34e2d3 --- /dev/null +++ b/templates/query/role/member_exists.sql.epp @@ -0,0 +1,22 @@ +USE [<%= $database %>]; +DECLARE + @role varchar(128) = '<%= $role %>', + @member varchar(128), + @error_msg varchar(250); + +<% $members.each |$member| { -%> +SET @member = '<%= $member %>'; +SET @error_msg = 'The member [<%= $member %>] is <% if $ensure == 'present' { %>not <% } %>a member of the role [<%=$role %>]'; +<%= epp('sqlserver/snippets/role/member_exists.sql.epp', { 'type' => $type }) -%> + THROW 51000, @error_msg, 10; +<% } %> + +<% if $members_purge { %> +IF EXISTS( +SELECT m.name FROM sys.<%= $type.downcase %>_role_members rm + JOIN sys.<%= $type.downcase %>_principals r ON rm.role_principal_id = r.principal_id + JOIN sys.<%= $type.downcase %>_principals m ON rm.member_principal_id = m.principal_id + WHERE r.name = '<%= $role %>' + <% if !$members.empty { %>AND m.name NOT IN (<%= $members.map |$m| { "'${m}'" }.join(',') %>)<% } %> +) THROW 51000, 'Unlisted Members in Role, will be purged', 10; +<% } %> diff --git a/templates/query/role/member_exists.sql.erb b/templates/query/role/member_exists.sql.erb deleted file mode 100644 index d532083b..00000000 --- a/templates/query/role/member_exists.sql.erb +++ /dev/null @@ -1,22 +0,0 @@ -USE [<%= @database %>]; -DECLARE - @role varchar(128) = '<%= @role %>', - @member varchar(128), - @error_msg varchar(250); - -<% @members.each do |member| %> -SET @member = '<%= member %>'; -SET @error_msg = 'The member [<%= member %>] is <% if @ensure == 'present'%>not <% end %>a member of the role [<%=@role %>]'; -<%= scope.function_template(['sqlserver/snippets/role/member_exists.sql.erb']) -%> - THROW 51000, @error_msg, 10; -<% end -%> - -<% if @members_purge %> -IF EXISTS( -SELECT m.name FROM sys.<%= @type.downcase %>_role_members rm - JOIN sys.<%= @type.downcase %>_principals r ON rm.role_principal_id = r.principal_id - JOIN sys.<%= @type.downcase %>_principals m ON rm.member_principal_id = m.principal_id - WHERE r.name = '<%= @role %>' - <% if !@members.empty? %>AND m.name NOT IN (<%= @members.collect{|m| "'#{m}'"}.join(',') %>)<% end %> -) THROW 51000, 'Unlisted Members in Role, will be purged', 10; -<% end -%> diff --git a/templates/query/role/permission_exists.sql.epp b/templates/query/role/permission_exists.sql.epp new file mode 100644 index 00000000..18270a1d --- /dev/null +++ b/templates/query/role/permission_exists.sql.epp @@ -0,0 +1,8 @@ +USE [<%= $database %>]; +<%= epp('sqlserver/snippets/role/declare_and_set_variables.sql.epp', $role_declare_and_set_variables_parameters) -%> + +<% $permissions.each |$requested_permission| { %> + <% $permission = $requested_permission.upcase %> +SET @permission = '<%= $permission %>'; +<%= epp('sqlserver/snippets/principal/permission/exists.sql.epp', { 'type' => $type }) -%> +<% } %> diff --git a/templates/query/role/permission_exists.sql.erb b/templates/query/role/permission_exists.sql.erb deleted file mode 100644 index 37eebcfe..00000000 --- a/templates/query/role/permission_exists.sql.erb +++ /dev/null @@ -1,9 +0,0 @@ -USE [<%= @database %>]; -<%= scope.function_template(['sqlserver/snippets/role/declare_and_set_variables.sql.erb']) -%> - -<% @permissions.each do |requested_permission| - permission = requested_permission.upcase -%> -SET @permission = '<%= permission %>'; -<%= scope.function_template(['sqlserver/snippets/principal/permission/exists.sql.erb']) -%> -<% end -%> diff --git a/templates/query/role_exists.sql.epp b/templates/query/role_exists.sql.epp new file mode 100644 index 00000000..7597dfc9 --- /dev/null +++ b/templates/query/role_exists.sql.epp @@ -0,0 +1,7 @@ +USE [<%= $database %>]; +<%= epp('sqlserver/snippets/role/exists.sql.epp', $role_exists_parameters) %> + THROW 51000, 'The <%= $type %> ROLE [<%= $role %>] does <% if $ensure == 'present' { %>not<% } %> exist', 10 +<% if $ensure == 'present' and $authorization { -%> + <%= epp('sqlserver/snippets/role/owner_check.sql.epp', $role_owner_check_parameters) %> + THROW 51000, 'The <%= $type %> ROLE [<%= $role %>] does not have the correct owner of [<%= $authorization %>]', 10 +<% } %> diff --git a/templates/query/role_exists.sql.erb b/templates/query/role_exists.sql.erb deleted file mode 100644 index 61ed61a0..00000000 --- a/templates/query/role_exists.sql.erb +++ /dev/null @@ -1,7 +0,0 @@ -USE [<%= @database %>]; -<%= scope.function_template(['sqlserver/snippets/role/exists.sql.erb']) %> - THROW 51000, 'The <%= @type %> ROLE [<%= @role %>] does <% if @ensure == 'present' %>not<% end %> exist', 10 -<% if @ensure == 'present' && @authorization -%> - <%= scope.function_template(['sqlserver/snippets/role/owner_check.sql.erb']) %> - THROW 51000, 'The <%= @type %> ROLE [<%= @role %>] does not have the correct owner of [<%= @authorization %>]', 10 -<% end -%> diff --git a/templates/query/sp_configure.sql.epp b/templates/query/sp_configure.sql.epp new file mode 100644 index 00000000..fdf15a5d --- /dev/null +++ b/templates/query/sp_configure.sql.epp @@ -0,0 +1,3 @@ +USE master; +IF EXISTS(SELECT * FROM sys.configurations WHERE name = '<%= $config_name %>' AND value_in_use != <%= $value %>) + THROW 51000, 'sp_configure `<%= $config_name %>` is not in the correct state', 10 diff --git a/templates/query/sp_configure.sql.erb b/templates/query/sp_configure.sql.erb deleted file mode 100644 index b6db5e8d..00000000 --- a/templates/query/sp_configure.sql.erb +++ /dev/null @@ -1,3 +0,0 @@ -USE master; -IF EXISTS(SELECT * FROM sys.configurations WHERE name = '<%= @config_name %>' AND value_in_use != <%= @value %>) - THROW 51000, 'sp_configure `<%= @config_name %>` is not in the correct state', 10 diff --git a/templates/query/user/permission_exists.sql.epp b/templates/query/user/permission_exists.sql.epp new file mode 100644 index 00000000..3d99358d --- /dev/null +++ b/templates/query/user/permission_exists.sql.epp @@ -0,0 +1,7 @@ +USE [<%= $database %>]; + +DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); +<% $permissions.each |$requested_permission| { %> + <% $permission = $requested_permission.upcase %> +<%= epp('sqlserver/snippets/user/permission/exists.sql.epp', $user_permission_exists_parameters) %> +<% } %> diff --git a/templates/query/user/permission_exists.sql.erb b/templates/query/user/permission_exists.sql.erb deleted file mode 100644 index 6faad555..00000000 --- a/templates/query/user/permission_exists.sql.erb +++ /dev/null @@ -1,9 +0,0 @@ -USE [<%= @database %>]; - -DECLARE @perm_state varchar(250), @error_msg varchar(250), @permission varchar(250); -<% @permissions.each do |requested_permission| - permission = requested_permission.upcase -%> -SET @permission = '<%= permission %>' -<%= scope.function_template(['sqlserver/snippets/user/permission/exists.sql.erb']) %> -<% end %> diff --git a/templates/query/user_exists.sql.epp b/templates/query/user_exists.sql.epp new file mode 100644 index 00000000..31bc944d --- /dev/null +++ b/templates/query/user_exists.sql.epp @@ -0,0 +1,4 @@ +-- Need to use exec instead of use statement as this will trigger try catch +USE [<%= $database %>]; +IF <% if $ensure == 'present' { %>NOT<% } %> EXISTS(SELECT name FROM sys.database_principals WHERE type in ('U','S','G') AND name = '<%= $user %>') + THROW 51000, 'User [<%= $user %>] does not exist for database [<%= $database %>]', 10 diff --git a/templates/query/user_exists.sql.erb b/templates/query/user_exists.sql.erb deleted file mode 100644 index 7fa0af5a..00000000 --- a/templates/query/user_exists.sql.erb +++ /dev/null @@ -1,4 +0,0 @@ --- Need to use exec instead of use statement as this will trigger try catch -USE [<%= @database %>]; -IF <% if @ensure == 'present' %>NOT<% end %> EXISTS(SELECT name FROM sys.database_principals WHERE type in ('U','S','G') AND name = '<%= @user %>') - THROW 51000, 'User [<%= @user %>] does not exist for database [<%= @database %>]', 10 diff --git a/templates/restart_service.ps1.epp b/templates/restart_service.ps1.epp new file mode 100644 index 00000000..3da46b81 --- /dev/null +++ b/templates/restart_service.ps1.epp @@ -0,0 +1,2 @@ +Restart-Service -Name '<%= $service_name %>' -Force + diff --git a/templates/restart_service.ps1.erb b/templates/restart_service.ps1.erb deleted file mode 100644 index 69921225..00000000 --- a/templates/restart_service.ps1.erb +++ /dev/null @@ -1,2 +0,0 @@ -Restart-Service -Name '<%= @service_name %>' -Force - diff --git a/templates/snippets/database/collation_exists.sql.epp b/templates/snippets/database/collation_exists.sql.epp new file mode 100644 index 00000000..d2fc786b --- /dev/null +++ b/templates/snippets/database/collation_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND collation_name = '<%= $collation_name %>') diff --git a/templates/snippets/database/collation_exists.sql.erb b/templates/snippets/database/collation_exists.sql.erb deleted file mode 100644 index 90340282..00000000 --- a/templates/snippets/database/collation_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND collation_name = '<%= @collation_name %>') diff --git a/templates/snippets/database/compatibility_exists.sql.epp b/templates/snippets/database/compatibility_exists.sql.epp new file mode 100644 index 00000000..56cc80d6 --- /dev/null +++ b/templates/snippets/database/compatibility_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND compatibility_level = <%= $compatibility %>) diff --git a/templates/snippets/database/compatibility_exists.sql.erb b/templates/snippets/database/compatibility_exists.sql.erb deleted file mode 100644 index 7d8e45fc..00000000 --- a/templates/snippets/database/compatibility_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND compatibility_level = <%= @compatibility %>) diff --git a/templates/snippets/database/containment_exists.sql.epp b/templates/snippets/database/containment_exists.sql.epp new file mode 100644 index 00000000..a04a3f8a --- /dev/null +++ b/templates/snippets/database/containment_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND containment_desc = '<%= $containment %>') diff --git a/templates/snippets/database/containment_exists.sql.erb b/templates/snippets/database/containment_exists.sql.erb deleted file mode 100644 index 4a140ea8..00000000 --- a/templates/snippets/database/containment_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND containment_desc = '<%= @containment %>') diff --git a/templates/snippets/database/db_chaining_exists.sql.epp b/templates/snippets/database/db_chaining_exists.sql.epp new file mode 100644 index 00000000..b087c9ca --- /dev/null +++ b/templates/snippets/database/db_chaining_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND is_db_chaining_on = <% if $db_chaining == 'ON' { %><%=1%><% }else { %><%=0%><% } %>) diff --git a/templates/snippets/database/db_chaining_exists.sql.erb b/templates/snippets/database/db_chaining_exists.sql.erb deleted file mode 100644 index 29d21339..00000000 --- a/templates/snippets/database/db_chaining_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND is_db_chaining_on = <%= @db_chaining == 'ON' ? 1 : 0 %>) diff --git a/templates/snippets/database/default_fulltext_language_exists.sql.erb b/templates/snippets/database/default_fulltext_language_exists.sql.epp similarity index 50% rename from templates/snippets/database/default_fulltext_language_exists.sql.erb rename to templates/snippets/database/default_fulltext_language_exists.sql.epp index 5b13c6ba..88689084 100644 --- a/templates/snippets/database/default_fulltext_language_exists.sql.erb +++ b/templates/snippets/database/default_fulltext_language_exists.sql.epp @@ -1,3 +1,3 @@ DECLARE @default_fulltext_lcid as INT -SELECT @default_fulltext_lcid = CONVERT(INT, lcid) FROM sys.syslanguages WHERE name = N'<%= @default_fulltext_language %>' OR alias = N'<%= @default_fulltext_language %>' -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND default_fulltext_language_lcid = @default_fulltext_lcid) +SELECT @default_fulltext_lcid = CONVERT(INT, lcid) FROM sys.syslanguages WHERE name = N'<%= $default_fulltext_language %>' OR alias = N'<%= $default_fulltext_language %>' +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND default_fulltext_language_lcid = @default_fulltext_lcid) diff --git a/templates/snippets/database/default_language_exists.sql.erb b/templates/snippets/database/default_language_exists.sql.epp similarity index 52% rename from templates/snippets/database/default_language_exists.sql.erb rename to templates/snippets/database/default_language_exists.sql.epp index 839dc8c1..60589015 100644 --- a/templates/snippets/database/default_language_exists.sql.erb +++ b/templates/snippets/database/default_language_exists.sql.epp @@ -1,3 +1,3 @@ DECLARE @default_language_lcid as INT -SELECT @default_language_lcid = CONVERT(INT,lcid) FROM sys.syslanguages WHERE name = N'<%= @default_language %>' OR alias = N'<%= @default_language %>' -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND DEFAULT_LANGUAGE_LCID = @default_language_lcid) +SELECT @default_language_lcid = CONVERT(INT,lcid) FROM sys.syslanguages WHERE name = N'<%= $default_language %>' OR alias = N'<%= $default_language %>' +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND DEFAULT_LANGUAGE_LCID = @default_language_lcid) diff --git a/templates/snippets/database/nested_triggers_exists.sql.epp b/templates/snippets/database/nested_triggers_exists.sql.epp new file mode 100644 index 00000000..062b20e3 --- /dev/null +++ b/templates/snippets/database/nested_triggers_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND is_nested_triggers_on = <% if $nested_triggers == 'ON' { %><%=1%><% }else { %><%=0%><% } %>) diff --git a/templates/snippets/database/nested_triggers_exists.sql.erb b/templates/snippets/database/nested_triggers_exists.sql.erb deleted file mode 100644 index 59a3a4c2..00000000 --- a/templates/snippets/database/nested_triggers_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND is_nested_triggers_on = <%= @nested_triggers == 'ON' ? 1 : 0 %>) diff --git a/templates/snippets/database/transform_noise_words_exists.sql.epp b/templates/snippets/database/transform_noise_words_exists.sql.epp new file mode 100644 index 00000000..113b4f0c --- /dev/null +++ b/templates/snippets/database/transform_noise_words_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND is_transform_noise_words_on = <% if $transform_noise_words == 'ON' { %><%=1%><% }else { %><%=0%><% } %>) diff --git a/templates/snippets/database/transform_noise_words_exists.sql.erb b/templates/snippets/database/transform_noise_words_exists.sql.erb deleted file mode 100644 index 753ad376..00000000 --- a/templates/snippets/database/transform_noise_words_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND is_transform_noise_words_on = <%= @transform_noise_words == 'ON' ? 1 : 0 %>) diff --git a/templates/snippets/database/trustworthy_exists.sql.epp b/templates/snippets/database/trustworthy_exists.sql.epp new file mode 100644 index 00000000..14de8f84 --- /dev/null +++ b/templates/snippets/database/trustworthy_exists.sql.epp @@ -0,0 +1 @@ +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= $db_name %>' AND is_trustworthy_on = <% if $trustworthy == 'ON' { %><%=1%><% }else { %><%=0%><% } %>) diff --git a/templates/snippets/database/trustworthy_exists.sql.erb b/templates/snippets/database/trustworthy_exists.sql.erb deleted file mode 100644 index ac6b1369..00000000 --- a/templates/snippets/database/trustworthy_exists.sql.erb +++ /dev/null @@ -1 +0,0 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = '<%= @db_name %>' AND is_trustworthy_on = <%= @trustworthy == 'ON' ? 1 : 0 %>) diff --git a/templates/snippets/database/two_digit_year_cutoff_exists.sql.erb b/templates/snippets/database/two_digit_year_cutoff_exists.sql.epp similarity index 52% rename from templates/snippets/database/two_digit_year_cutoff_exists.sql.erb rename to templates/snippets/database/two_digit_year_cutoff_exists.sql.epp index 3c77b722..b66e055d 100644 --- a/templates/snippets/database/two_digit_year_cutoff_exists.sql.erb +++ b/templates/snippets/database/two_digit_year_cutoff_exists.sql.epp @@ -1 +1 @@ -IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = N'<%= @db_name %>' AND two_digit_year_cutoff = <%= @two_digit_year_cutoff %>) +IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = N'<%= $db_name %>' AND two_digit_year_cutoff = <%= $two_digit_year_cutoff %>) diff --git a/templates/snippets/login/get_perm_state.sql.erb b/templates/snippets/login/get_perm_state.sql.epp similarity index 87% rename from templates/snippets/login/get_perm_state.sql.erb rename to templates/snippets/login/get_perm_state.sql.epp index 82b3b4a3..6a54df4f 100644 --- a/templates/snippets/login/get_perm_state.sql.erb +++ b/templates/snippets/login/get_perm_state.sql.epp @@ -2,6 +2,6 @@ ISNULL( (SELECT perm.state_desc FROM sys.server_permissions perm JOIN sys.server_principals princ ON princ.principal_id = perm.grantee_principal_id WHERE princ.type IN ('U','S','G') - AND princ.name = '<%= @login %>' + AND princ.name = '<%= $login %>' AND perm.permission_name = @permission), 'REVOKE') diff --git a/templates/snippets/login/permission/exists.sql.epp b/templates/snippets/login/permission/exists.sql.epp new file mode 100644 index 00000000..9737964a --- /dev/null +++ b/templates/snippets/login/permission/exists.sql.epp @@ -0,0 +1,4 @@ +SET @perm_state = <%= epp('sqlserver/snippets/login/get_perm_state.sql.epp', { 'login' => $login }) %>; +SET @error_msg = 'EXPECTED login [<%= $login %>] to have permission [' + @permission + '] with <%= $_state %> but got ' + @perm_state; +IF @perm_state != '<% if $with_grant_option == true { %>GRANT_WITH_GRANT_OPTION<% }else { %><%= $_state %><% } %>' + THROW 51000, @error_msg, 10; diff --git a/templates/snippets/login/permission/exists.sql.erb b/templates/snippets/login/permission/exists.sql.erb deleted file mode 100644 index b0ab2ae3..00000000 --- a/templates/snippets/login/permission/exists.sql.erb +++ /dev/null @@ -1,4 +0,0 @@ -SET @perm_state = <%= scope.function_template(['sqlserver/snippets/login/get_perm_state.sql.erb']) %>; -SET @error_msg = 'EXPECTED login [<%= @login %>] to have permission [' + @permission + '] with <%= @_state %> but got ' + @perm_state; -IF @perm_state != '<% if @with_grant_option == true %>GRANT_WITH_GRANT_OPTION<% else %><%= @_state %><% end %>' - THROW 51000, @error_msg, 10; diff --git a/templates/snippets/principal/permission/exists.sql.erb b/templates/snippets/principal/permission/exists.sql.epp similarity index 63% rename from templates/snippets/principal/permission/exists.sql.erb rename to templates/snippets/principal/permission/exists.sql.epp index 6d609a4e..504b8cce 100644 --- a/templates/snippets/principal/permission/exists.sql.erb +++ b/templates/snippets/principal/permission/exists.sql.epp @@ -1,4 +1,4 @@ -SET @perm_state = <%= scope.function_template(['sqlserver/snippets/principal/permission/get_perm_state.sql.erb']) -%>; +SET @perm_state = <%= epp('sqlserver/snippets/principal/permission/get_perm_state.sql.epp', { 'type' => $type }) -%>; SET @error_msg = 'EXPECTED [' + @princ_name + '] to have permission [' + @permission + '] with ' + @state_desc + ' but got ' + @perm_state; IF @perm_state != @state_desc THROW 51000, @error_msg, 10; diff --git a/templates/snippets/principal/permission/get_perm_state.sql.erb b/templates/snippets/principal/permission/get_perm_state.sql.epp similarity index 54% rename from templates/snippets/principal/permission/get_perm_state.sql.erb rename to templates/snippets/principal/permission/get_perm_state.sql.epp index 73d0ec30..000b7e8b 100644 --- a/templates/snippets/principal/permission/get_perm_state.sql.erb +++ b/templates/snippets/principal/permission/get_perm_state.sql.epp @@ -1,6 +1,6 @@ ISNULL( - (SELECT state_desc FROM sys.<%= @type.downcase %>_permissions prem - JOIN sys.<%= @type.downcase %>_principals r ON r.principal_id = prem.grantee_principal_id + (SELECT state_desc FROM sys.<%= $type.downcase %>_permissions prem + JOIN sys.<%= $type.downcase %>_principals r ON r.principal_id = prem.grantee_principal_id WHERE r.name = @princ_name AND r.type_desc = @princ_type AND prem.permission_name = @permission), 'REVOKE') diff --git a/templates/snippets/role/declare_and_set_variables.sql.epp b/templates/snippets/role/declare_and_set_variables.sql.epp new file mode 100644 index 00000000..a707bd44 --- /dev/null +++ b/templates/snippets/role/declare_and_set_variables.sql.epp @@ -0,0 +1,11 @@ +DECLARE + @perm_state varchar(250), + @error_msg varchar(250), + @permission varchar(250), + @princ_name varchar(50), + @princ_type varchar(50), + @state_desc varchar(50); + +SET @princ_type = '<%= $type.upcase %>_ROLE'; +SET @princ_name = '<%= $role %>'; +SET @state_desc = '<% if $with_grant_option == true { %>GRANT_WITH_GRANT_OPTION<% }else { %><%= $_state %><% } %>'; diff --git a/templates/snippets/role/declare_and_set_variables.sql.erb b/templates/snippets/role/declare_and_set_variables.sql.erb deleted file mode 100644 index b92fad95..00000000 --- a/templates/snippets/role/declare_and_set_variables.sql.erb +++ /dev/null @@ -1,11 +0,0 @@ -DECLARE - @perm_state varchar(250), - @error_msg varchar(250), - @permission varchar(250), - @princ_name varchar(50), - @princ_type varchar(50), - @state_desc varchar(50); - -SET @princ_type = '<%= @type.upcase %>_ROLE'; -SET @princ_name = '<%= @role %>'; -SET @state_desc = '<% if @with_grant_option == true %>GRANT_WITH_GRANT_OPTION<% else %><%= @_state %><% end %>'; diff --git a/templates/snippets/role/exists.sql.epp b/templates/snippets/role/exists.sql.epp new file mode 100644 index 00000000..e30d2d8c --- /dev/null +++ b/templates/snippets/role/exists.sql.epp @@ -0,0 +1,3 @@ +IF <% if $ensure == 'present' { %>NOT <% } %>EXISTS( + SELECT name FROM sys.<%= $type.downcase %>_principals WHERE type_desc = '<%= $type %>_ROLE' AND name = '<%= $role %>' +) diff --git a/templates/snippets/role/exists.sql.erb b/templates/snippets/role/exists.sql.erb deleted file mode 100644 index e3c7a18b..00000000 --- a/templates/snippets/role/exists.sql.erb +++ /dev/null @@ -1,3 +0,0 @@ -IF <% if @ensure == 'present' %>NOT <% end %>EXISTS( - SELECT name FROM sys.<%= @type.downcase %>_principals WHERE type_desc = '<%= @type %>_ROLE' AND name = '<%= @role %>' -) diff --git a/templates/snippets/role/member_exists.sql.epp b/templates/snippets/role/member_exists.sql.epp new file mode 100644 index 00000000..7e0442bd --- /dev/null +++ b/templates/snippets/role/member_exists.sql.epp @@ -0,0 +1,5 @@ +IF NOT EXISTS ( + SELECT r.name [Role], m.name [Member] FROM sys.<%= $type.downcase %>_role_members rm + JOIN sys.<%= $type.downcase %>_principals r ON rm.role_principal_id = r.principal_id + JOIN sys.<%= $type.downcase %>_principals m ON rm.member_principal_id = m.principal_id + WHERE r.name = @role AND m.name = @member) diff --git a/templates/snippets/role/member_exists.sql.erb b/templates/snippets/role/member_exists.sql.erb deleted file mode 100644 index 124dad35..00000000 --- a/templates/snippets/role/member_exists.sql.erb +++ /dev/null @@ -1,5 +0,0 @@ -IF NOT EXISTS ( - SELECT r.name [Role], m.name [Member] FROM sys.<%= @type.downcase %>_role_members rm - JOIN sys.<%= @type.downcase %>_principals r ON rm.role_principal_id = r.principal_id - JOIN sys.<%= @type.downcase %>_principals m ON rm.member_principal_id = m.principal_id - WHERE r.name = @role AND m.name = @member) diff --git a/templates/snippets/role/owner_check.sql.epp b/templates/snippets/role/owner_check.sql.epp new file mode 100644 index 00000000..17085e7c --- /dev/null +++ b/templates/snippets/role/owner_check.sql.epp @@ -0,0 +1,4 @@ +IF NOT EXISTS( + SELECT p.name,r.name FROM sys.<%= $type.downcase %>_principals r + JOIN sys.<%= $type.downcase %>_principals p ON p.principal_id = r.owning_principal_id + WHERE r.type_desc = '<%= $type.upcase %>_ROLE' AND p.name = '<%= $authorization %>' AND r.name = '<%= $role %>') diff --git a/templates/snippets/role/owner_check.sql.erb b/templates/snippets/role/owner_check.sql.erb deleted file mode 100644 index 1bc9a194..00000000 --- a/templates/snippets/role/owner_check.sql.erb +++ /dev/null @@ -1,4 +0,0 @@ -IF NOT EXISTS( - SELECT p.name,r.name FROM sys.<%= @type.downcase %>_principals r - JOIN sys.<%= @type.downcase %>_principals p ON p.principal_id = r.owning_principal_id - WHERE r.type_desc = '<%= @type.upcase %>_ROLE' AND p.name = '<%= @authorization %>' AND r.name = '<%= @role %>') diff --git a/templates/snippets/role/populate_purge_members.sql.epp b/templates/snippets/role/populate_purge_members.sql.epp new file mode 100644 index 00000000..3bd97b7f --- /dev/null +++ b/templates/snippets/role/populate_purge_members.sql.epp @@ -0,0 +1,11 @@ +DECLARE @purge_members TABLE ( +ID int IDENTITY(1,1), +member varchar(128) +) +INSERT INTO @purge_members (member) ( +SELECT m.name FROM sys.<%= $type.downcase %>_role_members rm + JOIN sys.<%= $type.downcase %>_principals r ON rm.role_principal_id = r.principal_id + JOIN sys.<%= $type.downcase %>_principals m ON rm.member_principal_id = m.principal_id + WHERE r.name = '<%= $role %>' + <% if !$members.empty { %>AND m.name NOT IN (<%= $members.map |$m| { "'${m}'" }.join(',') %>)<% } %> + ); diff --git a/templates/snippets/role/populate_purge_members.sql.erb b/templates/snippets/role/populate_purge_members.sql.erb deleted file mode 100644 index f6d18dcc..00000000 --- a/templates/snippets/role/populate_purge_members.sql.erb +++ /dev/null @@ -1,11 +0,0 @@ -DECLARE @purge_members TABLE ( -ID int IDENTITY(1,1), -member varchar(128) -) -INSERT INTO @purge_members (member) ( -SELECT m.name FROM sys.<%= @type.downcase %>_role_members rm - JOIN sys.<%= @type.downcase %>_principals r ON rm.role_principal_id = r.principal_id - JOIN sys.<%= @type.downcase %>_principals m ON rm.member_principal_id = m.principal_id - WHERE r.name = '<%= @role %>' - <% if !@members.empty? %>AND m.name NOT IN (<%= @members.collect{|m| "'#{m}'"}.join(',') %>)<% end %> - ); diff --git a/templates/snippets/user/permission/exists.sql.epp b/templates/snippets/user/permission/exists.sql.epp new file mode 100644 index 00000000..3f403223 --- /dev/null +++ b/templates/snippets/user/permission/exists.sql.epp @@ -0,0 +1,4 @@ +SET @perm_state = <%= epp('sqlserver/snippets/user/permission/get_perm_state.sql.epp', { 'user' => $user }) %>; +SET @error_msg = 'EXPECTED user [<%= $user %>] to have permission [' + @permission + '] with <%= $_state %> but got ' + @perm_state; +IF @perm_state != '<% if $with_grant_option == true { %>GRANT_WITH_GRANT_OPTION<% }else { %><%= $_state %><% } %>' + THROW 51000, @error_msg, 10 diff --git a/templates/snippets/user/permission/exists.sql.erb b/templates/snippets/user/permission/exists.sql.erb deleted file mode 100644 index fba5c4de..00000000 --- a/templates/snippets/user/permission/exists.sql.erb +++ /dev/null @@ -1,4 +0,0 @@ -SET @perm_state = <%= scope.function_template(['sqlserver/snippets/user/permission/get_perm_state.sql.erb']) %>; -SET @error_msg = 'EXPECTED user [<%= @user %>] to have permission [' + @permission + '] with <%= @_state %> but got ' + @perm_state; -IF @perm_state != '<% if @with_grant_option == true %>GRANT_WITH_GRANT_OPTION<% else %><%= @_state %><% end %>' - THROW 51000, @error_msg, 10 diff --git a/templates/snippets/user/permission/get_perm_state.sql.erb b/templates/snippets/user/permission/get_perm_state.sql.epp similarity index 77% rename from templates/snippets/user/permission/get_perm_state.sql.erb rename to templates/snippets/user/permission/get_perm_state.sql.epp index 2e92789d..7d7dd1d2 100644 --- a/templates/snippets/user/permission/get_perm_state.sql.erb +++ b/templates/snippets/user/permission/get_perm_state.sql.epp @@ -1,5 +1,5 @@ ISNULL( (SELECT perm.state_desc FROM sys.database_principals princ JOIN sys.database_permissions perm ON perm.grantee_principal_id = princ.principal_id - WHERE princ.type in ('U','S','G') AND name = '<%= @user %>' AND permission_name = @permission), + WHERE princ.type in ('U','S','G') AND name = '<%= $user %>' AND permission_name = @permission), 'REVOKE') From 170ddc9bc21fbd976f70488a74d11658d058bc28 Mon Sep 17 00:00:00 2001 From: rajat-puppet Date: Mon, 28 Aug 2023 14:06:02 +0530 Subject: [PATCH 17/43] Removing support and textual occurences of SQLSERVER 2012 --- README.md | 4 ++-- lib/puppet/provider/sqlserver_features/mssql.rb | 2 +- lib/puppet/provider/sqlserver_instance/mssql.rb | 2 +- lib/puppet_x/sqlserver/features.rb | 9 +-------- lib/puppet_x/sqlserver/server_helper.rb | 3 +-- metadata.json | 3 +-- provision.yaml | 4 ---- readmes/README_ja_JP.md | 4 ++-- spec/README.md | 4 ++-- spec/spec_helper_acceptance_local.rb | 9 +-------- spec/sql_testing_helpers.rb | 8 +------- 11 files changed, 13 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 7453ba7e..8b3c6d6e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## Overview -The sqlserver module installs and manages Microsoft SQL Server 2012, 2014, 2016, 2017, 2019 and 2022 on Windows systems. +The sqlserver module installs and manages Microsoft SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems. ## Module Description @@ -276,7 +276,7 @@ SQL 2017, 2019 and 2022 detection support has been added. This support is limite The MSOLEDBSQL driver is now required to use this module. You can use this chocolatey [package](https://community.chocolatey.org/packages/msoledbsql) for installation. but it must version 18.x or earlier. (v19+ is not currently supported) -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. +This module can manage only a single version of SQL Server on a given host (one and only one of SQL Server 2014, 2016, 2017, 2019 or 2022). The module is able to manage multiple SQL Server instances of the same version. 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. diff --git a/lib/puppet/provider/sqlserver_features/mssql.rb b/lib/puppet/provider/sqlserver_features/mssql.rb index 564b4fdb..1d01332e 100644 --- a/lib/puppet/provider/sqlserver_features/mssql.rb +++ b/lib/puppet/provider/sqlserver_features/mssql.rb @@ -122,7 +122,7 @@ def create instance_version = PuppetX::Sqlserver::ServerHelper.sql_version_from_install_source(@resource[:source]) Puppet.debug("Installation source detected as version #{instance_version}") unless instance_version.nil? - install_net35(@resource[:windows_feature_source]) if [SQL_2012, SQL_2014].include? instance_version + install_net35(@resource[:windows_feature_source]) if instance_version == SQL_2014 debug "Installing features #{@resource[:features]}" add_features(@resource[:features]) diff --git a/lib/puppet/provider/sqlserver_instance/mssql.rb b/lib/puppet/provider/sqlserver_instance/mssql.rb index b7cd3985..532a212e 100644 --- a/lib/puppet/provider/sqlserver_instance/mssql.rb +++ b/lib/puppet/provider/sqlserver_instance/mssql.rb @@ -107,7 +107,7 @@ def create instance_version = PuppetX::Sqlserver::ServerHelper.sql_version_from_install_source(@resource[:source]) Puppet.debug("Installation source detected as version #{instance_version}") unless instance_version.nil? - install_net35(@resource[:windows_feature_source]) if [SQL_2012, SQL_2014].include? instance_version + install_net35(@resource[:windows_feature_source]) if instance_version == SQL_2014 add_features(@resource[:features]) end diff --git a/lib/puppet_x/sqlserver/features.rb b/lib/puppet_x/sqlserver/features.rb index 20f649de..90491602 100644 --- a/lib/puppet_x/sqlserver/features.rb +++ b/lib/puppet_x/sqlserver/features.rb @@ -2,14 +2,13 @@ require 'puppet/util/windows' -SQL_2012 = 'SQL_2012' SQL_2014 = 'SQL_2014' SQL_2016 = 'SQL_2016' SQL_2017 = 'SQL_2017' SQL_2019 = 'SQL_2019' SQL_2022 = 'SQL_2022' -ALL_SQL_VERSIONS = [SQL_2012, SQL_2014, SQL_2016, SQL_2017, SQL_2019, SQL_2022].freeze +ALL_SQL_VERSIONS = [SQL_2014, SQL_2016, SQL_2017, SQL_2019, SQL_2022].freeze # rubocop:disable Style/ClassAndModuleChildren module PuppetX @@ -20,10 +19,6 @@ class Features # rubocop:disable Style/Documentation extend Puppet::Util::Windows::Registry SQL_CONFIGURATION = { - SQL_2012 => { - major_version: 11, - registry_path: '110' - }, SQL_2014 => { major_version: 12, registry_path: '120' @@ -181,7 +176,6 @@ def self.get_shared_features(version) # return a hash of version => instance info # # { - # "SQL_2012" => {}, # "SQL_2014" => { # "MSSQLSERVER" => { # "name" => "MSSQLSERVER", @@ -232,7 +226,6 @@ def self.instances # return a hash of version => shared features array # # { - # "SQL_2012" => ["Conn", "SDK", "MDS", "BC", "SSMS", "ADV_SSMS", "IS"], # "SQL_2014" => [] # } def self.features diff --git a/lib/puppet_x/sqlserver/server_helper.rb b/lib/puppet_x/sqlserver/server_helper.rb index f2daed42..68537817 100644 --- a/lib/puppet_x/sqlserver/server_helper.rb +++ b/lib/puppet_x/sqlserver/server_helper.rb @@ -20,7 +20,7 @@ def self.is_domain_or_local_user?(user, hostname) # rubocop:disable Naming/Predi !%r{(^(((nt (authority|service))|#{hostname})\\\w+)$)|^(\w+)$}i.match?(user) end - # Returns either SQL_2016, SQL_2014 or SQL_2012 if it can determine the SQL Version from the install source + # Returns either SQL_2016 or SQL_2014 if it can determine the SQL Version from the install source # Returns nil if it can not be determined def self.sql_version_from_install_source(source_dir) # Attempt to read the Mediainfo.xml file in the root of the install media @@ -48,7 +48,6 @@ def self.sql_version_from_install_source(source_dir) return SQL_2017 if ver[1].start_with?('14.') return SQL_2016 if ver[1].start_with?('13.') return SQL_2014 if ver[1].start_with?('12.') - return SQL_2012 if ver[1].start_with?('11.') nil end diff --git a/metadata.json b/metadata.json index 946913a3..79d28cfc 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "name": "puppetlabs-sqlserver", "version": "4.1.0", "author": "puppetlabs", - "summary": "The `sqlserver` module installs and manages MS SQL Server 2012, 2014, 2016, 2017, 2019 and 2022 on Windows systems.", + "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", "source": "https://github.com/puppetlabs/puppetlabs-sqlserver", "project_page": "https://github.com/puppetlabs/puppetlabs-sqlserver", @@ -40,7 +40,6 @@ "mssql", "sqlserver", "microsoft", - "sql2012", "sql2014", "sql2016", "sql2017", diff --git a/provision.yaml b/provision.yaml index 86837757..f1ca54cc 100644 --- a/provision.yaml +++ b/provision.yaml @@ -1,10 +1,6 @@ default: provisioner: vagrant images: ['gusztavvargadr/windows-server'] -release_checks_sql_2012: - provisioner: abs - images: ['win-2012r2-x86_64'] - vars: 'sqlversion: sqlserver_2012' release_checks_sql_2014_parity: provisioner: abs images: ['win-2012r2-x86_64'] diff --git a/readmes/README_ja_JP.md b/readmes/README_ja_JP.md index 24c65712..d649a283 100644 --- a/readmes/README_ja_JP.md +++ b/readmes/README_ja_JP.md @@ -20,7 +20,7 @@ ## 概要 -Microsoft SQL Server 2012、2014、2016、2017は、sqlserverモジュールにより、Windowsシステムでインストールと管理を行います。 +Microsoft SQL Server 2014、2016、2017は、sqlserverモジュールにより、Windowsシステムでインストールと管理を行います。 ## モジュールの概要 @@ -1070,7 +1070,7 @@ sys.configurationsで管理するオプションを指定します。有効な SQL 2017検出サポートが追加されました。このサポートはほかのバージョンの既存の機能に限定されます。SQL 2017に固有の新しい機能は、このリリースには追加されていません。 -このモジュールは、指定ホスト上のSQL Serverの単独バージョンのみ管理できます(SQL Server 2012、2014、2016のうちいずれか1つのみ)。このモジュールでは同一バージョンの複数のSQL Serverインスタンスを管理できます。 +このモジュールは、指定ホスト上のSQL Serverの単独バージョンのみ管理できます(SQL Server 2014、2016のうちいずれか1つのみ)。このモジュールでは同一バージョンの複数のSQL Serverインスタンスを管理できます。 このモジュールは、SQL Server Native Client SDK (別名SNAC_SDK)を管理できません。SQL ServerのインストールメディアはSDKをインストールできますが、SDKをアンインストールすることはできません。'sqlserver_features' factはSDKの存在を検出します。 diff --git a/spec/README.md b/spec/README.md index cc350543..7cf768ff 100644 --- a/spec/README.md +++ b/spec/README.md @@ -42,7 +42,7 @@ The Acceptance tets run on either a master and agent system or just on a stand-a First use beaker-hostgenerator to set up a hosts.yml to feed to the acceptance tests by running: ``` -bundle exec beaker-hostgenerator windows2012r2-64sql_host%2Cdefault.a%7Bsql_version=2012%7D-redhat7-64mdca --hypervisor abs > spec/acceptance/nodesets/hosts.yml +bundle exec beaker-hostgenerator windows2012r2-64sql_host%2Cdefault.a%7Bsql_version=2014%7D-redhat7-64mdca --hypervisor abs > spec/acceptance/nodesets/hosts.yml ``` This command assumes you're running it from the root of the sqlserver module repo. @@ -56,7 +56,7 @@ export ABS_RESOURCE_HOSTS="[{\"hostname\":\"\" e.g. replace "\" with "fyzskxlt6edanll.delivery.puppetlabs.net\" ``` -export ABS_RESOURCE_REQUESTS_beaker="[{\"windows2012r2-64sql_host.a%7Bsql_version=2012%7D-redhat7-64mdca\":{\"win-2012r2-x86_64\":1,\"redhat-7-x86_64\":1}, \"windows2012r2-64sql_host.a%7Bsql_version=2014%7D-redhat7-64mdca\":{\"win-2012r2-x86_64\":1,\"redhat-7-x86_64\":1}}]" +export ABS_RESOURCE_REQUESTS_beaker="[{\"windows2012r2-64sql_host.a%7Bsql_version=2014%7D-redhat7-64mdca\":{\"win-2012r2-x86_64\":1,\"redhat-7-x86_64\":1}, \"windows2012r2-64sql_host.a%7Bsql_version=2016%7D-redhat7-64mdca\":{\"win-2012r2-x86_64\":1,\"redhat-7-x86_64\":1}}]" export BEAKER_setfile=spec/acceptance/nodesets/hosts.yml export BEAKER_keyfile=/var/lib/jenkins/.ssh/id_rsa-acceptance diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 18a9767f..db2dfd38 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -16,7 +16,6 @@ class Helper SQL_2017_ISO = 'SQLServer2017-x64-ENU.iso' SQL_2016_ISO = 'en_sql_server_2016_enterprise_with_service_pack_1_x64_dvd_9542382.iso' SQL_2014_ISO = 'SQLServer2014SP3-FullSlipstream-x64-ENU.iso' -SQL_2012_ISO = 'SQLServer2012SP1-FullSlipstream-ENU-x64.iso' SQL_ADMIN_USER = 'sa' SQL_ADMIN_PASS = 'Pupp3t1@' USER = Helper.instance.run_shell('$env:UserName').stdout.chomp @@ -101,12 +100,6 @@ def mount_iso(opts = {}) def base_install(sql_version) case sql_version.to_i - when 2012 - iso_opts = { - folder: QA_RESOURCE_ROOT, - file: SQL_2012_ISO, - drive_letter: 'H' - } when 2014 iso_opts = { folder: QA_RESOURCE_ROOT, @@ -237,7 +230,7 @@ def validate_sql_install(opts = {}, &block) end def get_install_paths(version) - vers = { '2012' => '110', '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150', '2022' => '160' } + vers = { '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150', '2022' => '160' } raise _('Valid version must be specified') unless vers.key?(version) diff --git a/spec/sql_testing_helpers.rb b/spec/sql_testing_helpers.rb index 55a986b8..aacd6f1b 100644 --- a/spec/sql_testing_helpers.rb +++ b/spec/sql_testing_helpers.rb @@ -90,12 +90,6 @@ def run_sql_query(host, opts = {}, &block) def base_install(sql_version) case sql_version.to_i - when 2012 - iso_opts = { - folder: QA_RESOURCE_ROOT, - file: SQL_2012_ISO, - drive_letter: 'H' - } when 2014 iso_opts = { folder: QA_RESOURCE_ROOT, @@ -169,7 +163,7 @@ def remove_sql_instances(host, opts = {}) end def get_install_paths(version) - vers = { '2012' => '110', '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150', '2022' => '160' } + vers = { '2014' => '120', '2016' => '130', '2017' => '140', '2019' => '150', '2022' => '160' } raise _('Valid version must be specified') unless vers.key?(version) From 3d9a2902396fd6cce6dbef19489d92215ab37d1a Mon Sep 17 00:00:00 2001 From: Paula Muir Date: Thu, 31 Aug 2023 16:40:59 +0100 Subject: [PATCH 18/43] (maint) Update Issues URL Prior to this commit the issues URL directed the customer to an invalid location to raise a ticket. This PR updates the URL to link to the issues tab on the module Github Repo. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 946913a3..f156fe01 100644 --- a/metadata.json +++ b/metadata.json @@ -6,7 +6,7 @@ "license": "proprietary", "source": "https://github.com/puppetlabs/puppetlabs-sqlserver", "project_page": "https://github.com/puppetlabs/puppetlabs-sqlserver", - "issues_url": "https://tickets.puppet.com/browse/MODULES", + "issues_url": "https://github.com/puppetlabs/puppetlabs-sqlserver/issues", "dependencies": [ { "name": "puppetlabs/stdlib", From 227a786ddd34eb47787f9d48b49737f867b3d935 Mon Sep 17 00:00:00 2001 From: rajat-puppet Date: Mon, 6 Nov 2023 18:07:13 +0530 Subject: [PATCH 19/43] Adding github directory to pdkignore --- .pdkignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.pdkignore b/.pdkignore index c538bea8..960a62ab 100644 --- a/.pdkignore +++ b/.pdkignore @@ -31,6 +31,7 @@ /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore /.gitlab-ci.yml /.pdkignore From c8d2b0762ebb304986ed7ec2237178c0aa3b02e9 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Mon, 20 Nov 2023 11:32:16 +0530 Subject: [PATCH 20/43] "CAT-945 - Update README.md LICENSE" --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b3c6d6e..42e0bd3f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ * [Run custom TSQL statements](#run-custom-tsql-statements) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 6. [Limitations - OS compatibility, etc.](#limitations) -7. [Development - Guide for contributing to the module](#development) +7. [License](#license) +8. [Development - Guide for contributing to the module](#development) ## Overview @@ -282,6 +283,10 @@ This module cannot manage the SQL Server Native Client SDK (also known as SNAC_S In SQL Server 2016 and newer, Microsoft separated the installation of SQL Server Management Studio (SSMS) from the installation of the SQL Server engine and other features. SSMS now has its own installer and can be [installed and managed via Chocolatey](https://chocolatey.org/packages/sql-server-management-studio). As such, specifying SSMS in the `sqlserver` as a feature to install no longer works with SQL Server 2016 and newer. Instead, use `package` resources with the [Chocolatey provider](https://forge.puppet.com/puppetlabs/chocolatey) to manage SSMS installation. +## License + +This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of [AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html), [BSD-2](https://opensource.org/license/bsd-2-claus), [BSD-3](https://opensource.org/license/bsd-3-claus), [GPL2.0](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html), [LGPL](https://opensource.org/license/lgpl-3-0/), [MIT](https://opensource.org/license/mit/) and [MPL](https://opensource.org/license/mpl-2-0/) Licensing. + ## Development This module was built by Puppet specifically for use with Puppet Enterprise (PE). From fb8c4e59670350aa74b6d6bdef64ab43c578baf6 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Thu, 23 Nov 2023 09:58:22 +0530 Subject: [PATCH 21/43] Addressing review comments --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42e0bd3f..d3eeb7cf 100644 --- a/README.md +++ b/README.md @@ -285,7 +285,7 @@ In SQL Server 2016 and newer, Microsoft separated the installation of SQL Server ## License -This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of [AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html), [BSD-2](https://opensource.org/license/bsd-2-claus), [BSD-3](https://opensource.org/license/bsd-3-claus), [GPL2.0](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html), [LGPL](https://opensource.org/license/lgpl-3-0/), [MIT](https://opensource.org/license/mit/) and [MPL](https://opensource.org/license/mpl-2-0/) Licensing. +This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of [AGPL](https://opensource.org/license/agpl-v3/), [BSD-2](https://opensource.org/license/bsd-2-clause/), [BSD-3](https://opensource.org/license/bsd-3-clause/), [GPL2.0](https://opensource.org/license/gpl-2-0/), [LGPL](https://opensource.org/license/lgpl-3-0/), [MIT](https://opensource.org/license/mit/) and [MPL](https://opensource.org/license/mpl-2-0/) Licensing. ## Development From 615fe6422a87755f5281a1c4f8e36e460964fe31 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Tue, 28 Nov 2023 20:31:34 +0530 Subject: [PATCH 22/43] (CAT-1608) - PDK update --- .gitignore | 2 +- .pdkignore | 8 +- .rubocop.yml | 651 ++++++++++++++++++++++++++++++++++++++++- .rubocop_todo.yml | 171 +---------- .sync.yml | 2 - Gemfile | 50 ++-- Rakefile | 8 +- metadata.json | 4 +- spec/default_facts.yml | 6 +- spec/spec_helper.rb | 6 +- 10 files changed, 692 insertions(+), 216 deletions(-) diff --git a/.gitignore b/.gitignore index 988dcbbe..3f155121 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt diff --git a/.pdkignore b/.pdkignore index 960a62ab..862847a7 100644 --- a/.pdkignore +++ b/.pdkignore @@ -16,7 +16,7 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ /convert_report.txt @@ -26,21 +26,17 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml -/appveyor.yml -/.editorconfig /.fixtures.yml /Gemfile /.gitattributes /.github/ /.gitignore -/.gitlab-ci.yml /.pdkignore /.puppet-lint.rc /Rakefile /rakelib/ /.rspec -/.rubocop.yml -/.travis.yml +/..yml /.yardopts /spec/ /.vscode/ diff --git a/.rubocop.yml b/.rubocop.yml index e365cd83..7a66e083 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,15 +1,11 @@ --- -inherit_from: .rubocop_todo.yml - require: - rubocop-performance - rubocop-rspec AllCops: NewCops: enable DisplayCopNames: true - ExtraDetails: true - DisplayStyleGuide: true - TargetRubyVersion: '2.6' + TargetRubyVersion: '2.7' Include: - "**/*.rb" Exclude: @@ -23,6 +19,7 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" +inherit_from: ".rubocop_todo.yml" Layout/LineLength: Description: People have wide screens, use them. Max: 200 @@ -84,7 +81,645 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets -# RSpec/MultipleExpectations: -# Max: 3 +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true +Style/CollectionMethods: + Enabled: true +Style/MethodCalledOnDoEndBlock: + Enabled: true +Style/StringMethods: + Enabled: true +Bundler/GemFilename: + Enabled: false +Bundler/InsecureProtocolSource: + Enabled: false +Capybara/CurrentPathExpectation: + Enabled: false +Capybara/VisibilityMatcher: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: false +Layout/EndOfLine: + Enabled: false +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/BlockNesting: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/ParameterLists: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false Naming/MethodParameterName: - AllowedNames: 'is' + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/ContainExactly: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false +RSpec/DescribeClass: + Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false +RSpec/ExampleLength: + Enabled: false +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MatchArray: + Enabled: false +RSpec/MissingExampleGroupArgument: + Enabled: false +RSpec/MultipleExpectations: + Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false +RSpec/NestedGroups: + Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false +Style/SymbolProc: + Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Capybara/MatchStyle: + Enabled: false +Capybara/NegationMatcher: + Enabled: false +Capybara/SpecificActions: + Enabled: false +Capybara/SpecificFinders: + Enabled: false +Capybara/SpecificMatcher: + Enabled: false +Gemspec/DeprecatedAttributeAssignment: + Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false +Gemspec/RequireMFA: + Enabled: false +Layout/LineContinuationLeadingSpace: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false +Layout/LineEndStringConcatenationIndentation: + Enabled: false +Layout/SpaceBeforeBrackets: + Enabled: false +Lint/AmbiguousAssignment: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false +Lint/AmbiguousRange: + Enabled: false +Lint/ConstantOverwrittenInRescue: + Enabled: false +Lint/DeprecatedConstants: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateMagicComment: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/EmptyInPattern: + Enabled: false +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false +Lint/LambdaWithoutLiteralBlock: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/NumberedParameterAssignment: + Enabled: false +Lint/OrAssignmentToConstant: + Enabled: false +Lint/RedundantDirGlobSort: + Enabled: false +Lint/RefinementImportMethods: + Enabled: false +Lint/RequireRangeParentheses: + Enabled: false +Lint/RequireRelativeSelfPath: + Enabled: false +Lint/SymbolConversion: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/TripleQuotes: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Lint/UselessRescue: + Enabled: false +Lint/UselessRuby2Keywords: + Enabled: false +Metrics/CollectionLiteralLength: + Enabled: false +Naming/BlockForwarding: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Performance/ConcurrentMonotonicTime: + Enabled: false +Performance/MapCompact: + Enabled: false +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSplitRegexpArgument: + Enabled: false +Performance/StringIdentifierArgument: + Enabled: false +RSpec/BeEq: + Enabled: false +RSpec/BeNil: + Enabled: false +RSpec/ChangeByZero: + Enabled: false +RSpec/ClassCheck: + Enabled: false +RSpec/DuplicatedMetadata: + Enabled: false +RSpec/ExcessiveDocstringSpacing: + Enabled: false +RSpec/FactoryBot/ConsistentParenthesesStyle: + Enabled: false +RSpec/FactoryBot/FactoryNameStyle: + Enabled: false +RSpec/FactoryBot/SyntaxMethods: + Enabled: false +RSpec/IdenticalEqualityAssertion: + Enabled: false +RSpec/NoExpectationExample: + Enabled: false +RSpec/PendingWithoutReason: + Enabled: false +RSpec/Rails/AvoidSetupHook: + Enabled: false +RSpec/Rails/HaveHttpStatus: + Enabled: false +RSpec/Rails/InferredSpecType: + Enabled: false +RSpec/Rails/MinitestAssertions: + Enabled: false +RSpec/Rails/TravelAround: + Enabled: false +RSpec/RedundantAround: + Enabled: false +RSpec/SkipBlockInsideExample: + Enabled: false +RSpec/SortMetadata: + Enabled: false +RSpec/SubjectDeclaration: + Enabled: false +RSpec/VerifiedDoubleReference: + Enabled: false +Security/CompoundHash: + Enabled: false +Security/IoMethods: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/ArrayIntersect: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/ComparableClamp: + Enabled: false +Style/ConcatArrayLiterals: + Enabled: false +Style/DirEmpty: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/EmptyHeredoc: + Enabled: false +Style/EndlessMethod: + Enabled: false +Style/EnvHome: + Enabled: false +Style/FetchEnvVar: + Enabled: false +Style/FileEmpty: + Enabled: false +Style/FileRead: + Enabled: false +Style/FileWrite: + Enabled: false +Style/HashConversion: + Enabled: false +Style/HashExcept: + Enabled: false +Style/IfWithBooleanLiteralBranches: + Enabled: false +Style/InPatternThen: + Enabled: false +Style/MagicCommentFormat: + Enabled: false +Style/MapCompactWithConditionalBlock: + Enabled: false +Style/MapToHash: + Enabled: false +Style/MapToSet: + Enabled: false +Style/MinMaxComparison: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NestedFileDirname: + Enabled: false +Style/NilLambda: + Enabled: false +Style/NumberedParameters: + Enabled: false +Style/NumberedParametersLimit: + Enabled: false +Style/ObjectThen: + Enabled: false +Style/OpenStructUse: + Enabled: false +Style/OperatorMethodCall: + Enabled: false +Style/QuotedSymbols: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantDoubleSplatHashBraces: + Enabled: false +Style/RedundantEach: + Enabled: false +Style/RedundantHeredocDelimiterQuotes: + Enabled: false +Style/RedundantInitialize: + Enabled: false +Style/RedundantSelfAssignmentBranch: + Enabled: false +Style/RedundantStringEscape: + Enabled: false +Style/SelectByRegexp: + Enabled: false +Style/StringChars: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1ca51aea..f42ea7d4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,27 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-04-25 10:15:50 UTC using RuboCop version 1.48.1. +# on 2023-11-28 15:00:57 UTC using RuboCop version 1.48.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'spec/functions/sqlserver_upcase_spec.rb' - -# Offense count: 7 -# Configuration parameters: AllowComments, AllowEmptyLambdas. -Lint/EmptyBlock: - Exclude: - - 'lib/puppet/type/sqlserver_instance.rb' - - 'lib/puppet_x/sqlserver/features.rb' - - 'spec/defines/manifest_shared_examples.rb' - - 'spec/functions/functions_shared_examples.rb' - # Offense count: 3 # Configuration parameters: AllowComments, AllowNil. Lint/SuppressedException: @@ -29,68 +13,6 @@ Lint/SuppressedException: - 'lib/puppet_x/sqlserver/features.rb' - 'lib/puppet_x/sqlserver/sql_connection.rb' -# Offense count: 16 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. -Metrics/AbcSize: - Max: 36 - -# Offense count: 5 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 158 - -# Offense count: 1 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ClassLength: - Max: 158 - -# Offense count: 10 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/CyclomaticComplexity: - Max: 12 - -# Offense count: 39 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Max: 41 - -# Offense count: 10 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/PerceivedComplexity: - Max: 13 - -# Offense count: 12 -# Configuration parameters: ForbiddenDelimiters. -# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) -Naming/HeredocDelimiterNaming: - Exclude: - - 'lib/puppet/type/sqlserver_tsql.rb' - - 'spec/defines/database_spec.rb' - - 'spec/defines/login/permissions_spec.rb' - - 'spec/defines/login_spec.rb' - - 'spec/defines/sp_configure_spec.rb' - - 'spec/defines/user/permissions_spec.rb' - - 'spec/defines/user_spec.rb' - - 'spec/spec_helper_acceptance_local.rb' - - 'spec/sql_testing_helpers.rb' - -# Offense count: 66 -# Configuration parameters: Prefixes, AllowedPatterns. -# Prefixes: when, with, without -RSpec/ContextWording: - Enabled: false - -# Offense count: 28 -# Configuration parameters: IgnoredMetadata. -RSpec/DescribeClass: - Enabled: false - -# Offense count: 51 -# Configuration parameters: CountAsOne. -RSpec/ExampleLength: - Max: 59 - # Offense count: 2 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. # Include: **/*_spec*rb*, **/spec/**/* @@ -117,21 +39,7 @@ RSpec/InstanceVariable: - 'spec/unit/puppet/type/sqlserver_instance_spec.rb' - 'spec/unit/puppet_x/sql_connection_spec.rb' -# Offense count: 1 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/functions/sqlserver_upcase_spec.rb' - -# Offense count: 22 -RSpec/MultipleExpectations: - Max: 8 - -# Offense count: 10 -# Configuration parameters: AllowSubject. -RSpec/MultipleMemoizedHelpers: - Max: 10 - -# Offense count: 31 +# Offense count: 33 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -143,59 +51,7 @@ RSpec/NamedSubject: - 'spec/defines/role_spec.rb' - 'spec/defines/sp_configure_spec.rb' - 'spec/defines/user_spec.rb' - - 'spec/unit/puppet_x/sql_connection_spec.rb' - 'spec/functions/partial_params_args_spec.rb' - -# Offense count: 31 -# Configuration parameters: AllowedGroups. -RSpec/NestedGroups: - Max: 4 - -# Offense count: 70 -# Configuration parameters: AllowedPatterns. -# AllowedPatterns: ^expect_, ^assert_ -RSpec/NoExpectationExample: - Exclude: - - 'spec/acceptance/sqlserver_config_spec.rb' - - 'spec/acceptance/sqlserver_database_spec.rb' - - 'spec/acceptance/sqlserver_instance_spec.rb' - - 'spec/acceptance/sqlserver_login_spec.rb' - - 'spec/acceptance/sqlserver_role_spec.rb' - - 'spec/acceptance/sqlserver_tsql_spec.rb' - - 'spec/acceptance/sqlserver_user_spec.rb' - - 'spec/acceptance/z_last_sqlserver_features_spec.rb' - - 'spec/functions/sqlserver_upcase_spec.rb' - - 'spec/functions/sqlserver_validate_size_spec.rb' - - 'spec/unit/puppet/provider/sqlserver_features_spec.rb' - - 'spec/unit/puppet/provider/sqlserver_instance_spec.rb' - - 'spec/unit/puppet/provider/sqlserver_tsql_spec.rb' - - 'spec/unit/puppet/type/sqlserver_instance_spec.rb' - - 'spec/unit/puppet_x/server_helper_spec.rb' - -# Offense count: 4 -RSpec/RepeatedExampleGroupBody: - Exclude: - - 'spec/defines/login/permissions_spec.rb' - - 'spec/defines/user/permissions_spec.rb' - -# Offense count: 4 -RSpec/RepeatedExampleGroupDescription: - Exclude: - - 'spec/defines/config_spec.rb' - - 'spec/unit/puppet/provider/sqlserver_features_spec.rb' - -# Offense count: 7 -RSpec/StubbedMock: - Exclude: - - 'spec/unit/puppet/provider/sqlserver_features_spec.rb' - - 'spec/unit/puppet/provider/sqlserver_instance_spec.rb' - - 'spec/unit/puppet/provider/sqlserver_tsql_spec.rb' - - 'spec/unit/puppet_x/sql_connection_spec.rb' - -# Offense count: 2 -RSpec/SubjectDeclaration: - Exclude: - - 'spec/unit/puppet_x/server_helper_spec.rb' - 'spec/unit/puppet_x/sql_connection_spec.rb' # Offense count: 6 @@ -204,29 +60,16 @@ RSpec/SubjectStub: - 'spec/unit/puppet_x/server_helper_spec.rb' - 'spec/unit/puppet_x/sql_connection_spec.rb' -# Offense count: 4 -RSpec/UnspecifiedException: - Exclude: - - 'spec/functions/sqlserver_validate_hash_uniq_values_spec.rb' - - 'spec/functions/sqlserver_validate_instance_name_spec.rb' - # Offense count: 2 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: - 'spec/unit/puppet_x/sql_connection_spec.rb' -# Offense count: 7 -Security/Open: - Exclude: - - 'lib/puppet_x/sqlserver/features.rb' - - 'lib/puppet_x/sqlserver/sql_connection.rb' - -# Offense count: 3 -# Configuration parameters: AllowedMethods. -# AllowedMethods: respond_to_missing? -Style/OptionalBooleanParameter: +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. +# MethodsAcceptingSymbol: inject, reduce +Style/CollectionMethods: Exclude: - 'lib/puppet/provider/sqlserver_instance/mssql.rb' - - 'lib/puppet/type/sqlserver_tsql.rb' - - 'spec/defines/manifest_shared_examples.rb' diff --git a/.sync.yml b/.sync.yml index 9a7be77a..505552ce 100644 --- a/.sync.yml +++ b/.sync.yml @@ -33,5 +33,3 @@ spec/spec_helper.rb: unmanaged: false .travis.yml: delete: true -.rubocop.yml: - unmanaged: true diff --git a/Gemfile b/Gemfile index 918691c7..c67df239 100644 --- a/Gemfile +++ b/Gemfile @@ -14,32 +14,36 @@ def location_for(place_or_version, fake_version = nil) end group :development do - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "voxpupuli-puppet-lint-plugins", '~> 4.0', require: false - gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '>= 2.0.2', '< 4.0.0', require: false - gem "puppetlabs_spec_helper", '~> 5.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false - gem "dependency_checker", '~> 0.2', require: false - gem "parallel_tests", '= 3.12.1', require: false - gem "pry", '~> 0.10', require: false - gem "simplecov-console", '~> 0.5', require: false - gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false - gem "rubocop-performance", '= 1.16.0', require: false - gem "rubocop-rspec", '= 2.19.0', require: false - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "ruby-pwsh", require: false - gem "github_changelog_generator", '= 1.15.2', require: false + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false + gem "facterdb", '~> 1.18', require: false + gem "metadata-json-lint", '~> 3.0', require: false + gem "rspec-puppet-facts", '~> 2.0', require: false + gem "codecov", '~> 0.2', require: false + gem "dependency_checker", '~> 1.0.0', require: false + gem "parallel_tests", '= 3.12.1', require: false + gem "pry", '~> 0.10', require: false + gem "simplecov-console", '~> 0.5', require: false + gem "puppet-debugger", '~> 1.0', require: false + gem "rubocop", '= 1.48.1', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "ruby-pwsh", require: false + gem "github_changelog_generator", '= 1.15.2', require: false end group :system_tests do gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "serverspec", '~> 2.41', require: false + gem "serverspec", '~> 2.41', require: false +end +group :release_prep do + gem "puppet-strings", '~> 4.0', require: false + gem "puppetlabs_spec_helper", '~> 7.0', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 53152e21..74415a96 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,11 @@ # frozen_string_literal: true require 'bundler' -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? +require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? +require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator' +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' def changelog_user return unless Rake.application.top_level_tasks.include? "changelog" @@ -43,7 +43,7 @@ end PuppetLint.configuration.send('disable_relative') -if Bundler.rubygems.find_name('github_changelog_generator').any? +if Gem.loaded_specs.key? 'github_changelog_generator' GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? config.user = "#{changelog_user}" diff --git a/metadata.json b/metadata.json index 4d340b03..67e9faa7 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,7 @@ "tsql", "database" ], - "pdk-version": "2.7.1", + "pdk-version": "3.0.0", "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", - "template-ref": "tags/2.7.5-0-ge5b0114" + "template-ref": "heads/main-0-g01c6a19" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index f3946607..3346c394 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -3,7 +3,7 @@ # Facts specified here will override the values provided by rspec-puppet-facts. --- networking: - ip: "172.16.254.254" - ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" - mac: "AA:AA:AA:AA:AA:AA" + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ec79997f..f5ec906d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,11 +9,11 @@ require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) -include RspecPuppetFacts # rubocop:disable Style/MixinUsage +include RspecPuppetFacts default_facts = { puppetversion: Puppet.version, - facterversion: Facter.version + facterversion: Facter.version, } default_fact_files = [ @@ -25,7 +25,7 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) + default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end From c1a3d4a6538bce72263b9891ab66e6129befc306 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Thu, 21 Dec 2023 10:20:23 +0530 Subject: [PATCH 23/43] PDK update --- .sync.yml | 2 -- Gemfile | 5 ++-- Rakefile | 79 --------------------------------------------------- metadata.json | 2 +- 4 files changed, 4 insertions(+), 84 deletions(-) diff --git a/.sync.yml b/.sync.yml index 505552ce..8790ca00 100644 --- a/.sync.yml +++ b/.sync.yml @@ -10,8 +10,6 @@ Gemfile: optional: ":development": - gem: ruby-pwsh - - gem: github_changelog_generator - version: '= 1.15.2' spec/spec_helper.rb: mock_with: ":rspec" coverage_report: true diff --git a/Gemfile b/Gemfile index c67df239..b044d8e1 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ group :development do gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false gem "facterdb", '~> 1.18', require: false gem "metadata-json-lint", '~> 3.0', require: false + gem "puppetlabs_spec_helper", '~> 6.0', require: false gem "rspec-puppet-facts", '~> 2.0', require: false gem "codecov", '~> 0.2', require: false gem "dependency_checker", '~> 1.0.0', require: false @@ -33,9 +34,9 @@ group :development do gem "rubocop", '= 1.48.1', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false + gem "puppet-strings", '~> 4.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "ruby-pwsh", require: false - gem "github_changelog_generator", '= 1.15.2', require: false end group :system_tests do gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] @@ -43,7 +44,7 @@ group :system_tests do end group :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 7.0', require: false + gem "puppetlabs_spec_helper", '~> 6.0', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 74415a96..77590fe6 100644 --- a/Rakefile +++ b/Rakefile @@ -4,85 +4,6 @@ require 'bundler' require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator' require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -end - -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - - returnVal = nil - returnVal ||= begin - metadata_source = JSON.load(File.read('metadata.json'))['source'] - metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) - - metadata_source_match && metadata_source_match[1] - end - - raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? - - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal -end - -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal -end - PuppetLint.configuration.send('disable_relative') - - -if Gem.loaded_specs.key? 'github_changelog_generator' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["enhancement", "feature"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bug", "documentation", "bugfix"], - }, - } - end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise < 1.15' - condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" -EOM - end -end - diff --git a/metadata.json b/metadata.json index 67e9faa7..ed63c741 100644 --- a/metadata.json +++ b/metadata.json @@ -50,5 +50,5 @@ ], "pdk-version": "3.0.0", "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", - "template-ref": "heads/main-0-g01c6a19" + "template-ref": "heads/main-0-g79a2f93" } From 19d435be7c2e63f45f08cd928549162de34e85ee Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Wed, 20 Dec 2023 16:27:12 +0000 Subject: [PATCH 24/43] (Bug) - Remove default switch of updateenabled false Prior to this commit, since v3.3.0 of this module, the Install switch /UpdateEnabled always defaulted to FALSE when the instance /ACTION=Install. This took away the ability for users to be able to configure this install switch themselves, and is an obvious bug. Now, this no longer automatically prepends the flag to install switches when action=install, and allows users to configure this through install_switches property once again. --- lib/puppet/provider/sqlserver_features/mssql.rb | 1 - lib/puppet/provider/sqlserver_instance/mssql.rb | 1 - spec/acceptance/sqlserver_config_spec.rb | 1 + spec/acceptance/sqlserver_instance_spec.rb | 3 +++ spec/acceptance/z_last_sqlserver_features_spec.rb | 3 +++ spec/spec_helper_acceptance_local.rb | 2 +- spec/sql_testing_helpers.rb | 2 +- spec/unit/puppet/provider/sqlserver_instance_spec.rb | 4 +--- spec/unit/puppet/sqlserver_spec_helper.rb | 1 - 9 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/puppet/provider/sqlserver_features/mssql.rb b/lib/puppet/provider/sqlserver_features/mssql.rb index 1d01332e..e5cb7176 100644 --- a/lib/puppet/provider/sqlserver_features/mssql.rb +++ b/lib/puppet/provider/sqlserver_features/mssql.rb @@ -67,7 +67,6 @@ def modify_features(action, features) '/IACCEPTSQLSERVERLICENSETERMS', "/FEATURES=#{features.join(',')}"] if action == 'install' - cmd_args << '/UPDATEENABLED=False' cmd_args << "/ISSVCACCOUNT=#{@resource[:is_svc_account]}" if not_nil_and_not_empty?(@resource[:is_svc_account]) cmd_args << "/ISSVCPASSWORD=#{@resource[:is_svc_password]}" if not_nil_and_not_empty?(@resource[:is_svc_password]) cmd_args << "/PID=#{@resource[:pid]}" if not_nil_and_not_empty?(@resource[:pid]) diff --git a/lib/puppet/provider/sqlserver_instance/mssql.rb b/lib/puppet/provider/sqlserver_instance/mssql.rb index 532a212e..3d2320fd 100644 --- a/lib/puppet/provider/sqlserver_instance/mssql.rb +++ b/lib/puppet/provider/sqlserver_instance/mssql.rb @@ -142,7 +142,6 @@ def basic_cmd_args(features, action) '/IACCEPTSQLSERVERLICENSETERMS', "/INSTANCENAME=#{@resource[:name]}"] cmd_args << "/FEATURES=#{features.join(',')}" unless features.empty? - cmd_args << '/UPDATEENABLED=False' if action == 'install' cmd_args end diff --git a/spec/acceptance/sqlserver_config_spec.rb b/spec/acceptance/sqlserver_config_spec.rb index 6bf9a8d3..16139cc5 100644 --- a/spec/acceptance/sqlserver_config_spec.rb +++ b/spec/acceptance/sqlserver_config_spec.rb @@ -22,6 +22,7 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present') sa_pwd => 'Pupp3t1@', windows_feature_source => 'I:\\sources\\sxs', install_switches => { + 'UpdateEnabled' => 'false', 'SkipInstallerRunCheck' => 'True', }, } diff --git a/spec/acceptance/sqlserver_instance_spec.rb b/spec/acceptance/sqlserver_instance_spec.rb index e2ba6c4f..d6934415 100644 --- a/spec/acceptance/sqlserver_instance_spec.rb +++ b/spec/acceptance/sqlserver_instance_spec.rb @@ -30,6 +30,9 @@ def ensure_sqlserver_instance(features, inst_name, ensure_val = 'present', sysad agt_svc_account => '#{user}', agt_svc_password => '#{password}', windows_feature_source => 'I:\\sources\\sxs', + install_switches => { + 'UpdateEnabled' => 'false', + }, } MANIFEST idempotent_apply(pp) diff --git a/spec/acceptance/z_last_sqlserver_features_spec.rb b/spec/acceptance/z_last_sqlserver_features_spec.rb index 75881cdb..a0d9eabc 100644 --- a/spec/acceptance/z_last_sqlserver_features_spec.rb +++ b/spec/acceptance/z_last_sqlserver_features_spec.rb @@ -25,6 +25,9 @@ def ensure_sql_features(features, ensure_val = 'present') is_svc_password => '#{password}', features => #{features}, windows_feature_source => 'I:\\sources\\sxs', + install_switches => { + 'UpdateEnabled' => 'false', + } } MANIFEST diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index db2dfd38..f886db7d 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -148,7 +148,7 @@ def install_sqlserver(features) sa_pwd => 'Pupp3t1@', sql_sysadmin_accounts => ['#{USER}'], install_switches => { - 'UPDATEENABLED' => 'False', + 'UpdateEnabled' => 'false', 'TCPENABLED' => 1, 'SQLBACKUPDIR' => 'C:\\MSSQLSERVER\\backupdir', 'SQLTEMPDBDIR' => 'C:\\MSSQLSERVER\\tempdbdir', diff --git a/spec/sql_testing_helpers.rb b/spec/sql_testing_helpers.rb index aacd6f1b..ed07a376 100644 --- a/spec/sql_testing_helpers.rb +++ b/spec/sql_testing_helpers.rb @@ -33,7 +33,7 @@ def install_sqlserver(host, opts = {}) sa_pwd => 'Pupp3t1@', sql_sysadmin_accounts => ['#{user}'], install_switches => { - 'UPDATEENABLED' => 'False', + 'UpdateEnabled' => 'false', 'TCPENABLED' => 1, 'SQLBACKUPDIR' => 'C:\\MSSQLSERVER\\backupdir', 'SQLTEMPDBDIR' => 'C:\\MSSQLSERVER\\tempdbdir', diff --git a/spec/unit/puppet/provider/sqlserver_instance_spec.rb b/spec/unit/puppet/provider/sqlserver_instance_spec.rb index 67edab38..3a8f5fae 100644 --- a/spec/unit/puppet/provider/sqlserver_instance_spec.rb +++ b/spec/unit/puppet/provider/sqlserver_instance_spec.rb @@ -57,8 +57,7 @@ def stub_uninstall(args, installed_features, exit_code = 0) '/Q', '/IACCEPTSQLSERVERLICENSETERMS', "/INSTANCENAME=#{execute_args[:name]}", - "/FEATURES=#{execute_args[:features].join(',')}", - '/UPDATEENABLED=False'] + "/FEATURES=#{execute_args[:features].join(',')}"] (execute_args.keys - ['ensure', 'loglevel', 'features', 'name', 'source', 'sql_sysadmin_accounts', 'sql_security_mode', 'install_switches'].map(&:to_sym)).sort.map do |key| cmd_args << "/#{resourcekey_to_cmdarg[key.to_s]}=\"#{@resource[key]}\"" end @@ -96,7 +95,6 @@ def stub_uninstall(args, installed_features, exit_code = 0) '/ACTION=install', '/Q', '/IACCEPTSQLSERVERLICENSETERMS', - '/UPDATEENABLED=False', "/INSTANCENAME=#{execute_args[:name]}", "/FEATURES=#{execute_args[:features].join(',')}"] (execute_args.keys - ['ensure', 'loglevel', 'features', 'name', 'source', 'sql_sysadmin_accounts', 'sql_security_mode', 'install_switches'].map(&:to_sym)).sort.map do |key| diff --git a/spec/unit/puppet/sqlserver_spec_helper.rb b/spec/unit/puppet/sqlserver_spec_helper.rb index 217776a9..d5d5a872 100644 --- a/spec/unit/puppet/sqlserver_spec_helper.rb +++ b/spec/unit/puppet/sqlserver_spec_helper.rb @@ -23,7 +23,6 @@ def stub_modify_features(action, args, features, additional_switches = [], exit_ '/Q', '/IACCEPTSQLSERVERLICENSETERMS', "/FEATURES=#{features.join(',')}"] - cmds << '/UPDATEENABLED=False' if action == 'install' cmds << "/ISSVCACCOUNT=#{args[:is_svc_account]}" if args.key?(:is_svc_account) cmds << "/ISSVCPASSWORD=#{args[:is_svc_password]}" if args.key?(:is_svc_password) additional_switches.each do |switch| From c716834d7237344c04fcafff0864cbb56e4352d6 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 16 Feb 2024 10:56:22 +0000 Subject: [PATCH 25/43] Release prep v5.0.0 --- CHANGELOG.md | 23 ++++++++++++++++++++--- REFERENCE.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 2 +- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bac7bb12..9e87e6ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v5.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.0) - 2024-02-16 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v4.1.0...v5.0.0) + +### Changed +- [CAT-1065] : Removing support for SQL Server 2012 [#455](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/455) ([rajat-puppet](https://github.com/rajat-puppet)) + +### Added + +- (CAT-1148) Conversion of ERB to EPP [#454](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/454) ([praj1001](https://github.com/praj1001)) + +### Fixed + +- (Bug) - Remove default switch of UpdateEnabled=false when Action=Install [#466](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/466) ([jordanbreen28](https://github.com/jordanbreen28)) +- (bugfix) Update Issues URL [#456](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/456) ([pmcmaw](https://github.com/pmcmaw)) + ## [v4.1.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v4.1.0) - 2023-06-27 [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v4.0.0...v4.1.0) @@ -66,13 +82,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.2...v3.0.0) +### Changed +- pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#369](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/369) ([carabasdaniel](https://github.com/carabasdaniel)) + ### Added - pdksync - (feat) - Add support for Puppet 7 [#363](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/363) ([daianamezdrea](https://github.com/daianamezdrea)) -### Changed -- pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#369](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/369) ([carabasdaniel](https://github.com/carabasdaniel)) - ### Fixed - (FM-8879) Handle T-SQL Errors Properly [#349](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/349) ([RandomNoun7](https://github.com/RandomNoun7)) @@ -390,6 +406,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - (MODULES-2430) Fix issue parsing facts with puppet 4 [#133](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/133) ([cyberious](https://github.com/cyberious)) - (FM-3252) CI Pipeline for sqlserver at step 7a [#132](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/132) ([phongdly](https://github.com/phongdly)) - (MODULES-2403) Improve error handling for sqlserver_tsql [#131](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/131) ([cyberious](https://github.com/cyberious)) +- (MODULES-2377) Add validation for sp_configure bools [#130](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/130) ([cyberious](https://github.com/cyberious)) - (docs) Several docs updates [#129](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/129) ([cyberious](https://github.com/cyberious)) - (docs) MODULES-2325 update readme to reflect permissions [#128](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/128) ([cyberious](https://github.com/cyberious)) - (DO NOT MERGE)(MODULES-2312) Use sp_executesql to execute T-SQL [#127](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/127) ([Iristyle](https://github.com/Iristyle)) diff --git a/REFERENCE.md b/REFERENCE.md index 2bff6413..42183610 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -24,6 +24,8 @@ ### Functions +* [`sqlserver::partial_params_args`](#sqlserver--partial_params_args): this function populates and returns the string of arguments which later gets injected in template. +* [`sqlserver::password`](#sqlserver--password): This function exists for usage of a role password that is a deferred function * [`sqlserver_is_domain_or_local_user`](#sqlserver_is_domain_or_local_user) * [`sqlserver_upcase`](#sqlserver_upcase) * [`sqlserver_validate_hash_uniq_values`](#sqlserver_validate_hash_uniq_values) @@ -1208,6 +1210,50 @@ usually discover the appropriate provider for your platform. ## Functions +### `sqlserver::partial_params_args` + +Type: Ruby 4.x API + +arguments that return string holds is conditional and decided by the the input given to function. + +#### `sqlserver::partial_params_args(Hash $args)` + +arguments that return string holds is conditional and decided by the the input given to function. + +Returns: `Variant[String]` String +Generated on the basis of provided values. + +##### `args` + +Data type: `Hash` + +contains +Enum['ON', 'OFF'] $db_chaining +Enum['ON', 'OFF'] $trustworthy +String[1] $default_fulltext_language +String[1] $default_language +Optional[Enum['ON', 'OFF']] $nested_triggers +Optional[Enum['ON', 'OFF']] $transform_noise_words +Integer[1753, 9999] $two_digit_year_cutoff + +### `sqlserver::password` + +Type: Ruby 4.x API + +This function exists for usage of a role password that is a deferred function + +#### `sqlserver::password(Optional[Any] $pass)` + +This function exists for usage of a role password that is a deferred function + +Returns: `Any` + +##### `pass` + +Data type: `Optional[Any]` + + + ### `sqlserver_is_domain_or_local_user` Type: Ruby 3.x API diff --git a/metadata.json b/metadata.json index ed63c741..90f91541 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "4.1.0", + "version": "5.0.0", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From ed97d7c0c057fd906d72c9c0092e40e81bb74df5 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Wed, 21 Feb 2024 20:37:08 +0530 Subject: [PATCH 26/43] (CAT-1728) - Unable to use password function as deferred function --- .github/workflows/release.yml | 2 +- .rubocop.yml | 6 ++++++ .vscode/extensions.json | 2 +- Gemfile | 7 +++---- REFERENCE.md | 19 ------------------- lib/puppet/functions/sqlserver/password.rb | 13 ------------- manifests/login.pp | 5 ++++- manifests/user.pp | 5 ++++- metadata.json | 2 +- spec/functions/password_spec.rb | 8 -------- 10 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 lib/puppet/functions/sqlserver/password.rb delete mode 100644 spec/functions/password_spec.rb diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b7b8a05..4b3b80fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: "Publish module" on: workflow_dispatch: - + jobs: release: uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" diff --git a/.rubocop.yml b/.rubocop.yml index 7a66e083..e6bd5af8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -529,6 +529,8 @@ Lint/DuplicateBranch: Enabled: false Lint/DuplicateMagicComment: Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false Lint/DuplicateRegexpCharacterClassElement: Enabled: false Lint/EmptyBlock: @@ -645,6 +647,8 @@ Style/ComparableClamp: Enabled: false Style/ConcatArrayLiterals: Enabled: false +Style/DataInheritance: + Enabled: false Style/DirEmpty: Enabled: false Style/DocumentDynamicEvalDefinition: @@ -713,6 +717,8 @@ Style/RedundantHeredocDelimiterQuotes: Enabled: false Style/RedundantInitialize: Enabled: false +Style/RedundantLineContinuation: + Enabled: false Style/RedundantSelfAssignmentBranch: Enabled: false Style/RedundantStringEscape: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2f1e4f73..6da8d472 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ "puppet.puppet-vscode", - "rebornix.Ruby" + "Shopify.ruby-lsp" ] } diff --git a/Gemfile b/Gemfile index b044d8e1..d6e99877 100644 --- a/Gemfile +++ b/Gemfile @@ -22,16 +22,15 @@ group :development do gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '~> 3.0', require: false + gem "metadata-json-lint", '~> 4.0', require: false gem "puppetlabs_spec_helper", '~> 6.0', require: false gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false - gem "simplecov-console", '~> 0.5', require: false + gem "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false + gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "puppet-strings", '~> 4.0', require: false diff --git a/REFERENCE.md b/REFERENCE.md index 42183610..b84d6da1 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -25,7 +25,6 @@ ### Functions * [`sqlserver::partial_params_args`](#sqlserver--partial_params_args): this function populates and returns the string of arguments which later gets injected in template. -* [`sqlserver::password`](#sqlserver--password): This function exists for usage of a role password that is a deferred function * [`sqlserver_is_domain_or_local_user`](#sqlserver_is_domain_or_local_user) * [`sqlserver_upcase`](#sqlserver_upcase) * [`sqlserver_validate_hash_uniq_values`](#sqlserver_validate_hash_uniq_values) @@ -1236,24 +1235,6 @@ Optional[Enum['ON', 'OFF']] $nested_triggers Optional[Enum['ON', 'OFF']] $transform_noise_words Integer[1753, 9999] $two_digit_year_cutoff -### `sqlserver::password` - -Type: Ruby 4.x API - -This function exists for usage of a role password that is a deferred function - -#### `sqlserver::password(Optional[Any] $pass)` - -This function exists for usage of a role password that is a deferred function - -Returns: `Any` - -##### `pass` - -Data type: `Optional[Any]` - - - ### `sqlserver_is_domain_or_local_user` Type: Ruby 3.x API diff --git a/lib/puppet/functions/sqlserver/password.rb b/lib/puppet/functions/sqlserver/password.rb deleted file mode 100644 index 8abf0b88..00000000 --- a/lib/puppet/functions/sqlserver/password.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# This function exists for usage of a role password that is a deferred function -Puppet::Functions.create_function(:'sqlserver::password') do - dispatch :password do - optional_param 'Any', :pass - return_type 'Any' - end - - def password(pass) - pass - end -end diff --git a/manifests/login.pp b/manifests/login.pp index fd2f1442..a081f462 100644 --- a/manifests/login.pp +++ b/manifests/login.pp @@ -80,7 +80,10 @@ $create_delete_login_parameters = { 'disabled' => $disabled, 'login' => $login, - 'password' => Deferred('sqlserver::password', [$password]), + 'password' => $password ? { + undef => undef, + default => Deferred('sprintf', [$password]), + }, 'check_expiration' => $check_expiration, 'check_policy' => $check_policy, 'default_language' => $default_language, diff --git a/manifests/user.pp b/manifests/user.pp index eb92a1c6..e2f8503b 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -65,7 +65,10 @@ if $create_delete == 'create' { $create_delete_user_parameters = { 'database' => $database, - 'password' => Deferred('sqlserver::password', [$password]), + 'password' => $password ? { + undef => undef, + default => Deferred('sprintf', [$password]), + }, 'user' => $user, 'login' => $login, 'default_schema' => $default_schema, diff --git a/metadata.json b/metadata.json index 90f91541..d977db1f 100644 --- a/metadata.json +++ b/metadata.json @@ -50,5 +50,5 @@ ], "pdk-version": "3.0.0", "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", - "template-ref": "heads/main-0-g79a2f93" + "template-ref": "heads/main-0-g0f7378b" } diff --git a/spec/functions/password_spec.rb b/spec/functions/password_spec.rb deleted file mode 100644 index 54010644..00000000 --- a/spec/functions/password_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'sqlserver::password' do - it { is_expected.to run.with_params('password').and_return('password') } - it { is_expected.to run.with_params(nil).and_return(nil) } -end From 0265c68abd3c8e8e1e3f0c17e88b30496aba5e26 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 22 Feb 2024 04:18:05 +0000 Subject: [PATCH 27/43] Release prep v5.0.1 --- CHANGELOG.md | 8 ++++++++ metadata.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e87e6ae..38ea790e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v5.0.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.1) - 2024-02-22 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.0...v5.0.1) + +### Fixed + +- (CAT-1728) - Unable to use password function as deferred function [#469](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/469) ([Ramesh7](https://github.com/Ramesh7)) + ## [v5.0.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.0) - 2024-02-16 [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v4.1.0...v5.0.0) diff --git a/metadata.json b/metadata.json index d977db1f..e5022d0d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "5.0.0", + "version": "5.0.1", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From 7bb66df1c176772d0d5e1400e7fefe15cbb8a5b3 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:09:39 +0530 Subject: [PATCH 28/43] Fix mend to run on cron --- .github/workflows/mend.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml index b4100a5a..8b5b4018 100644 --- a/.github/workflows/mend.yml +++ b/.github/workflows/mend.yml @@ -1,9 +1,10 @@ name: "mend" on: - pull_request: - branches: - - "main" + pull_request_target: + types: + - opened + - synchronize schedule: - cron: "0 0 * * *" workflow_dispatch: From 6d577b0ae86d3f973e897d7056cc238c13c408b7 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 21 May 2024 21:21:40 +0530 Subject: [PATCH 29/43] ITHELP-87329 : replace pull_request_target with pull_request --- .github/workflows/mend.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml index 8b5b4018..b4100a5a 100644 --- a/.github/workflows/mend.yml +++ b/.github/workflows/mend.yml @@ -1,10 +1,9 @@ name: "mend" on: - pull_request_target: - types: - - opened - - synchronize + pull_request: + branches: + - "main" schedule: - cron: "0 0 * * *" workflow_dispatch: From b8dc3daf17e2ad90db5ca521c880a403ca33561a Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Thu, 23 May 2024 10:48:56 +0530 Subject: [PATCH 30/43] (maint) - Update CI Workflows --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64fa4f84..27d87ff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,9 @@ name: "ci" on: - pull_request_target: - types: [opened, synchronize, reopened] + pull_request: + branches: + - "main" workflow_dispatch: env: From 4fb8c854314e79e2383e75da569c6dce97857436 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:58:43 +0530 Subject: [PATCH 31/43] ITHELP-87329 : replace pull_request_target with pull_request --- .github/workflows/labeller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml index ee149bf5..0d4870d7 100644 --- a/.github/workflows/labeller.yml +++ b/.github/workflows/labeller.yml @@ -6,7 +6,7 @@ on: - opened - labeled - unlabeled - pull_request_target: + pull_request: types: - opened - labeled From 4f4a020ca691046b2ceed6834472776e18937050 Mon Sep 17 00:00:00 2001 From: Ramesh Sencha Date: Thu, 18 Jul 2024 11:21:38 +0530 Subject: [PATCH 32/43] (CAT-1939) Reverting deferred function changes --- manifests/login.pp | 7 ++----- manifests/user.pp | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/manifests/login.pp b/manifests/login.pp index a081f462..3787919e 100644 --- a/manifests/login.pp +++ b/manifests/login.pp @@ -80,10 +80,7 @@ $create_delete_login_parameters = { 'disabled' => $disabled, 'login' => $login, - 'password' => $password ? { - undef => undef, - default => Deferred('sprintf', [$password]), - }, + 'password' => $password, 'check_expiration' => $check_expiration, 'check_policy' => $check_policy, 'default_language' => $default_language, @@ -111,7 +108,7 @@ sqlserver_tsql { "login-${instance}-${login}": instance => $instance, - command => stdlib::deferrable_epp("sqlserver/${_create_delete}/login.sql.epp", $create_delete_login_parameters), + command => epp("sqlserver/${_create_delete}/login.sql.epp", $create_delete_login_parameters), onlyif => epp('sqlserver/query/login_exists.sql.epp', $query_login_exists_parameters), require => Sqlserver::Config[$instance], } diff --git a/manifests/user.pp b/manifests/user.pp index e2f8503b..f58e043f 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -65,10 +65,7 @@ if $create_delete == 'create' { $create_delete_user_parameters = { 'database' => $database, - 'password' => $password ? { - undef => undef, - default => Deferred('sprintf', [$password]), - }, + 'password' => $password, 'user' => $user, 'login' => $login, 'default_schema' => $default_schema, @@ -88,7 +85,7 @@ sqlserver_tsql { "user-${instance}-${database}-${user}": instance => $instance, - command => stdlib::deferrable_epp("sqlserver/${create_delete}/user.sql.epp", $create_delete_user_parameters), + command => epp("sqlserver/${create_delete}/user.sql.epp", $create_delete_user_parameters), onlyif => epp('sqlserver/query/user_exists.sql.epp', $query_user_exists_parameters), require => Sqlserver::Config[$instance], } From 9dfcb42f356513c5e9f0023d1e716de02bf9adfa Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 18 Jul 2024 14:15:02 +0000 Subject: [PATCH 33/43] Release prep v5.0.2 --- CHANGELOG.md | 11 +++++++++++ metadata.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ea790e..e969fa94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v5.0.2](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.2) - 2024-07-18 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.1...v5.0.2) + +### Fixed + +- (CAT-1939) Reverting deferred function changes [#477](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/477) ([Ramesh7](https://github.com/Ramesh7)) + ## [v5.0.1](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.1) - 2024-02-22 [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.0...v5.0.1) @@ -18,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v4.1.0...v5.0.0) ### Changed + - [CAT-1065] : Removing support for SQL Server 2012 [#455](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/455) ([rajat-puppet](https://github.com/rajat-puppet)) ### Added @@ -43,6 +52,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v3.3.0...v4.0.0) ### Changed + - (CONT-800) - Add Puppet 8/Drop Puppet 6 [#430](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/430) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v3.3.0](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v3.3.0) - 2023-03-07 @@ -91,6 +101,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v2.6.2...v3.0.0) ### Changed + - pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#369](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/369) ([carabasdaniel](https://github.com/carabasdaniel)) ### Added diff --git a/metadata.json b/metadata.json index e5022d0d..c51c2006 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "5.0.1", + "version": "5.0.2", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From 75621b5b6301125318264677ea767aa894a3af8a Mon Sep 17 00:00:00 2001 From: rajat-puppet Date: Mon, 22 Jul 2024 17:31:20 +0530 Subject: [PATCH 34/43] Remove labeller.yml --- .github/workflows/labeller.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/labeller.yml diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml deleted file mode 100644 index 0d4870d7..00000000 --- a/.github/workflows/labeller.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Labeller - -on: - issues: - types: - - opened - - labeled - - unlabeled - pull_request: - types: - - opened - - labeled - - unlabeled - -jobs: - label: - runs-on: ubuntu-latest - steps: - - - uses: puppetlabs/community-labeller@v1.0.1 - name: Label issues or pull requests - with: - label_name: community - label_color: '5319e7' - org_membership: puppetlabs - fail_if_member: 'true' - token: ${{ secrets.IAC_COMMUNITY_LABELER }} From 2e7987d0c3ab4114ff522a047b4a938ec0674849 Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Tue, 15 Oct 2024 20:18:42 +0530 Subject: [PATCH 35/43] pdksync - (PF-3525) - pdk update for module --- .gitignore | 7 +++++++ .pdkignore | 7 +++++++ .rubocop.yml | 2 +- Gemfile | 21 +++++++++++---------- metadata.json | 4 ++-- spec/spec_helper.rb | 5 +++-- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 3f155121..2803e566 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,3 +27,9 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 862847a7..84684be6 100644 --- a/.pdkignore +++ b/.pdkignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,6 +27,12 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes diff --git a/.rubocop.yml b/.rubocop.yml index e6bd5af8..439ea84e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.7' + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: diff --git a/Gemfile b/Gemfile index d6e99877..5abcd642 100644 --- a/Gemfile +++ b/Gemfile @@ -20,11 +20,11 @@ group :development do gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.2.2', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 1.18', require: false + gem "facterdb", '~> 2.1', require: false gem "metadata-json-lint", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false @@ -33,17 +33,18 @@ group :development do gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false - gem "puppet-strings", '~> 4.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "rexml", '>= 3.0.0', '< 3.2.7', require: false gem "ruby-pwsh", require: false end -group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "serverspec", '~> 2.41', require: false -end -group :release_prep do +group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false + gem "puppetlabs_spec_helper", '~> 7.0', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/metadata.json b/metadata.json index c51c2006..abd95502 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,7 @@ "tsql", "database" ], - "pdk-version": "3.0.0", + "pdk-version": "3.2.0", "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", - "template-ref": "heads/main-0-g0f7378b" + "template-ref": "tags/3.2.0.4-0-g5d17ec1" } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f5ec906d..fec9b602 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,8 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end @@ -33,7 +34,7 @@ # read default_facts and merge them over what is provided by facterdb default_facts.each do |fact, value| - add_custom_fact fact, value + add_custom_fact fact, value, merge_facts: true end RSpec.configure do |c| From 0906b8dd6fe483a5942b1c1f40e1bfeb2a8f739b Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Wed, 13 Nov 2024 13:22:06 +0530 Subject: [PATCH 36/43] (CAT-2158) Upgrade rexml to address CVE-2024-49761 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5abcd642..2c483db9 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ group :development do gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.0.0', '< 3.2.7', require: false + gem "rexml", '>= 3.3.9', require: false gem "ruby-pwsh", require: false end group :development, :release_prep do From ca0282ce32d23fbb2e00b96c54675af21951f10b Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Mon, 17 Feb 2025 09:15:13 +0530 Subject: [PATCH 37/43] (CAT-2222) Update legacy facts --- lib/facter/sqlserver_features.rb | 2 +- lib/facter/sqlserver_instances.rb | 2 +- lib/puppet/provider/sqlserver.rb | 2 +- spec/defines/config_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/facter/sqlserver_features.rb b/lib/facter/sqlserver_features.rb index 5e66a9dd..a102e1bd 100644 --- a/lib/facter/sqlserver_features.rb +++ b/lib/facter/sqlserver_features.rb @@ -3,7 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'puppet_x/sqlserver/features')) Facter.add(:sqlserver_features) do - confine osfamily: :windows + confine 'os.family': :windows setcode do PuppetX::Sqlserver::Features.features diff --git a/lib/facter/sqlserver_instances.rb b/lib/facter/sqlserver_instances.rb index 37ccea86..7d03db89 100644 --- a/lib/facter/sqlserver_instances.rb +++ b/lib/facter/sqlserver_instances.rb @@ -3,7 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'puppet_x/sqlserver/features')) Facter.add(:sqlserver_instances) do - confine osfamily: :windows + confine 'os.family': :windows setcode do PuppetX::Sqlserver::Features.instances diff --git a/lib/puppet/provider/sqlserver.rb b/lib/puppet/provider/sqlserver.rb index e06c0ae1..2af0ec2d 100644 --- a/lib/puppet/provider/sqlserver.rb +++ b/lib/puppet/provider/sqlserver.rb @@ -6,7 +6,7 @@ require 'tempfile' class Puppet::Provider::Sqlserver < Puppet::Provider # rubocop:disable Style/Documentation - confine operatingsystem: :windows + confine 'os.name': :windows initvars diff --git a/spec/defines/config_spec.rb b/spec/defines/config_spec.rb index cd48f323..d6af527e 100644 --- a/spec/defines/config_spec.rb +++ b/spec/defines/config_spec.rb @@ -5,7 +5,7 @@ RSpec.describe 'sqlserver::config', type: :define do let(:title) { 'MSSQLSERVER' } - let(:facts) { { osfamily: 'windows', platform: 'windows', puppet_vardir: 'C:/ProgramData/PuppetLabs/puppet/var' } } + let(:facts) { { 'os.family': 'windows', platform: 'windows', puppet_vardir: 'C:/ProgramData/PuppetLabs/puppet/var' } } describe 'compile' do let(:params) do From d96aac39f4f5c5e27c1d7a8520a53537d9ca183f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 18 Feb 2025 07:17:50 +0000 Subject: [PATCH 38/43] Release prep v5.0.3 --- CHANGELOG.md | 8 ++++++++ metadata.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e969fa94..e03affdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v5.0.3](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.3) - 2025-02-18 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.2...v5.0.3) + +### Fixed + +- (CAT-2222) Update legacy facts [#485](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/485) ([amitkarsale](https://github.com/amitkarsale)) + ## [v5.0.2](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.2) - 2024-07-18 [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.1...v5.0.2) diff --git a/metadata.json b/metadata.json index abd95502..453b7aca 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "5.0.2", + "version": "5.0.3", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From 4d32badb0f91193c1d2fb4d4e124f0e3b15762b4 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 18 Feb 2025 07:22:38 +0000 Subject: [PATCH 39/43] Release prep v5.0.4 --- CHANGELOG.md | 4 ++-- metadata.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e03affdb..afe9bc73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). -## [v5.0.3](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.3) - 2025-02-18 +## [v5.0.4](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.4) - 2025-02-18 -[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.2...v5.0.3) +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.2...v5.0.4) ### Fixed diff --git a/metadata.json b/metadata.json index 453b7aca..7074d8fc 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "5.0.3", + "version": "5.0.4", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From f90ce76a6317521f3ff1b124221228e3b7daace8 Mon Sep 17 00:00:00 2001 From: Maqsood Ahmad Date: Wed, 11 Jun 2025 15:13:26 +0530 Subject: [PATCH 40/43] MODULES-11577 chore(ruby): upgrade Ruby from 2.7 to 3.1 --- .github/workflows/nightly.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9d718e3c..b23a0087 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -27,11 +27,11 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} if: ${{ github.repository_owner == 'puppetlabs' }} - - name: Activate Ruby 2.7 + - name: Activate Ruby 3.1 uses: ruby/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: - ruby-version: "2.7" + ruby-version: "3.1" bundler-cache: true - name: Print bundle environment @@ -67,10 +67,10 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - - name: Activate Ruby 2.7 + - name: Activate Ruby 3.1 uses: ruby/setup-ruby@v1 with: - ruby-version: "2.7" + ruby-version: "3.1" bundler-cache: true - name: Print bundle environment From c8d9476a83cf97060f3ba021fb9378647b374ddd Mon Sep 17 00:00:00 2001 From: Saurabh Pandit Date: Wed, 18 Jun 2025 17:14:05 +0530 Subject: [PATCH 41/43] (MODULES-11567): Enhance validation methods to resolve deferred values for validation in sqlserver_instance type --- .github/workflows/ci.yml | 10 +-- lib/puppet/type/sqlserver_instance.rb | 15 +++- spec/acceptance/sqlserver_instance_spec.rb | 69 +++++++++++++++++++ .../puppet/type/sqlserver_instance_spec.rb | 24 +++++++ 4 files changed, 110 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27d87ff8..5d1405c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,11 +29,11 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} if: ${{ github.repository_owner == 'puppetlabs' }} - - name: Activate Ruby 2.7 + - name: Activate Ruby 3.1 uses: ruby/setup-ruby@v1 if: ${{ github.repository_owner == 'puppetlabs' }} with: - ruby-version: "2.7" + ruby-version: "3.1" bundler-cache: true - name: Print bundle environment @@ -69,10 +69,10 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - - name: Activate Ruby 2.7 + - name: Activate Ruby 3.1 uses: ruby/setup-ruby@v1 with: - ruby-version: "2.7" + ruby-version: "3.1" bundler-cache: true - name: Print bundle environment @@ -93,7 +93,7 @@ jobs: run: | bundle exec rake 'litmus:install_module' - - name: Authenitcate with GCP + - name: Authenticate with GCP run: | echo '${{ secrets.GCP_CONNECTION }}' >> creds.json bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml diff --git a/lib/puppet/type/sqlserver_instance.rb b/lib/puppet/type/sqlserver_instance.rb index b33f4d09..5afb7dcd 100644 --- a/lib/puppet/type/sqlserver_instance.rb +++ b/lib/puppet/type/sqlserver_instance.rb @@ -131,7 +131,8 @@ def validate end def set?(key) - !self[key].nil? && !self[key].empty? + self_key = resolve_deferred_value(self[key]) + !self_key.nil? && !self_key.empty? end def validate_user_password_required(account, pass) @@ -144,11 +145,11 @@ def validate_user_password_required(account, pass) end def domain_or_local_user?(user) - PuppetX::Sqlserver::ServerHelper.is_domain_or_local_user?(user, Facter.value(:hostname)) + PuppetX::Sqlserver::ServerHelper.is_domain_or_local_user?(resolve_deferred_value(user), Facter.value(:hostname)) end def strong_password?(key) - password = self[key] + password = resolve_deferred_value(self[key]) return unless password message_start = "Password for #{key} is not strong" @@ -162,4 +163,12 @@ def strong_password?(key) true end + + # When preprocess_deferred is false, deferred values remain unresolved at the time of validation, causing it to fail. + # To address this, following logic is added to explicitly resolve deferred values during validation + def resolve_deferred_value(value) + return value unless value.is_a?(Puppet::Pops::Evaluator::DeferredValue) + + value.resolve + end end diff --git a/spec/acceptance/sqlserver_instance_spec.rb b/spec/acceptance/sqlserver_instance_spec.rb index d6934415..f9af473b 100644 --- a/spec/acceptance/sqlserver_instance_spec.rb +++ b/spec/acceptance/sqlserver_instance_spec.rb @@ -134,4 +134,73 @@ def sql_query_is_user_sysadmin(username) end end end + + # Ensure that the instance can be created with deferred values + # for service account and password, which are resolved at the time of + # the instance creation. + # This is useful for scenarios where the values are not known at the time + # of the Puppet run, such as when using Hiera to fetch values from a + # secure vault or when the values are dynamically generated. + def ensure_sqlserver_instance_with_deferred_values(inst_name) + features = ['SQLEngine', 'Replication', 'FullText', 'DQ'] + host_computer_name = run_shell('CMD /C ECHO %COMPUTERNAME%').stdout.chomp + sysadmin_accounts = ["#{host_computer_name}\\travis"] + user = Helper.instance.run_shell('$env:UserName').stdout.chomp + password = Helper.instance.run_shell('$env:pass').stdout.chomp + password = 'Hunter-2' if password.empty? + + pp = <<-MANIFEST + sqlserver_instance{'#{inst_name}': + name => '#{inst_name}', + ensure => 'present', + source => 'H:', + security_mode => 'SQL', + sa_pwd => 'Pupp3t1@', + features => #{features}, + sql_sysadmin_accounts => #{sysadmin_accounts}, + agt_svc_account => Deferred('pick', ['#{user}']), + agt_svc_password => Deferred('pick', ['#{password}']), + windows_feature_source => 'I:\\sources\\sxs', + install_switches => { + 'UpdateEnabled' => 'false', + }, + } + MANIFEST + + idempotent_apply(pp) + end + + context 'Deferred values' do + before(:context) do + @deferred_user = 'travis' + pp = <<-MANIFEST + user { '#{@deferred_user}': + ensure => present, + password => 'Puppet01!', + } + MANIFEST + apply_manifest(pp, catch_failures: true) + end + + after(:context) do + pp = <<-MANIFEST + user { '#{@deferred_user}': + ensure => absent, + } + MANIFEST + apply_manifest(pp, catch_failures: true) + end + + it 'validate deferred values' do + inst_name = new_random_instance_name + expect { ensure_sqlserver_instance_with_deferred_values(inst_name) }.not_to raise_error + end + + it 'apply deferred values' do + inst_name = new_random_instance_name + ensure_sqlserver_instance_with_deferred_values(inst_name) + + run_sql_query(run_sql_query_opts(inst_name, sql_query_is_user_sysadmin(@deferred_user), 1)) + end + end end diff --git a/spec/unit/puppet/type/sqlserver_instance_spec.rb b/spec/unit/puppet/type/sqlserver_instance_spec.rb index e3d87bda..de04ecf6 100644 --- a/spec/unit/puppet/type/sqlserver_instance_spec.rb +++ b/spec/unit/puppet/type/sqlserver_instance_spec.rb @@ -84,4 +84,28 @@ end end end + + describe 'agt_svc_account' do + context 'when value is a deferred value' do + let(:args) do + basic_args.merge({ agt_svc_account: Puppet::Pops::Evaluator::DeferredValue.new(proc { 'nexus\\travis' }) }) + end + + it 'validate' do + subject = Puppet::Type.type(:sqlserver_instance).new(args) + expect(subject.resolve_deferred_value(subject[:agt_svc_account])).to eq('nexus\\travis') + end + end + + context 'when value is not a deferred value' do + let(:args) do + basic_args.merge({ agt_svc_account: 'nexus\\travis' }) + end + + it 'validate' do + subject = Puppet::Type.type(:sqlserver_instance).new(args) + expect(subject.resolve_deferred_value(subject[:agt_svc_account])).to eq('nexus\\travis') + end + end + end end From 135a42cc731de3705e1c0a8008465927a530fa50 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 20 Jun 2025 09:47:44 +0000 Subject: [PATCH 42/43] Release prep v5.0.5 --- CHANGELOG.md | 8 ++++++++ metadata.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afe9bc73..7649e0e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v5.0.5](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.5) - 2025-06-20 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.4...v5.0.5) + +### Fixed + +- (MODULES-11567): Enhance validation methods to resolve deferred values for validation in sqlserver_instance type [#487](https://github.com/puppetlabs/puppetlabs-sqlserver/pull/487) ([span786](https://github.com/span786)) + ## [v5.0.4](https://github.com/puppetlabs/puppetlabs-sqlserver/tree/v5.0.4) - 2025-02-18 [Full Changelog](https://github.com/puppetlabs/puppetlabs-sqlserver/compare/v5.0.2...v5.0.4) diff --git a/metadata.json b/metadata.json index 7074d8fc..996fb358 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-sqlserver", - "version": "5.0.4", + "version": "5.0.5", "author": "puppetlabs", "summary": "The `sqlserver` module installs and manages MS SQL Server 2014, 2016, 2017, 2019 and 2022 on Windows systems.", "license": "proprietary", From 4b002441bd599e0210752abd37877c410f21e496 Mon Sep 17 00:00:00 2001 From: Maqsood Ahmad Date: Mon, 7 Jul 2025 21:36:59 +0530 Subject: [PATCH 43/43] ci(MODULES-11557): add Twingate setup step to GitHub Actions workflow Adds the Twingate installation step in `.github/workflows/...` using `twingate/github-action@v1`. The action uses the `${{ secrets.TWINGATE_KEY }}` to establish secure access to internal resources. This enables the workflow to access protected infrastructure during CI runs. --- .github/workflows/ci.yml | 5 +++++ .github/workflows/nightly.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d1405c5..817353ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,11 @@ jobs: FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' steps: + - name: "Install Twingate" + uses: "twingate/github-action@v1" + with: + service-key: ${{ secrets.TWINGATE_PUBLIC_REPO_KEY }} + - name: Checkout uses: actions/checkout@v3 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b23a0087..64a5e662 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -62,6 +62,11 @@ jobs: FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' steps: + - name: "Install Twingate" + uses: "twingate/github-action@v1" + with: + service-key: ${{ secrets.TWINGATE_PUBLIC_REPO_KEY }} + - name: Checkout uses: actions/checkout@v3 with: