Skip to content

pdksync - (Maint) PDK Update #401

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV
echo STEP_START=$(date +%s) >> $GITHUB_ENV
# - name: Run Static & Syntax Tests
# if: ${{ github.repository_owner == 'puppetlabs' }}
# run: |
# buildevents cmd $TRACE_ID $STEP_ID 'static_syntax_checks' -- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
- name: Run Static & Syntax Tests
if: ${{ github.repository_owner == 'puppetlabs' }}
run: |
buildevents cmd $TRACE_ID $STEP_ID 'static_syntax_checks' -- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop

- name: Setup Spec Test Matrix
id: get-matrix
Expand Down
3 changes: 3 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
--relative
--no-parameter_types-check
--no-params_empty_string_assignment-check
--no-unquoted_string_in_selector-check
5 changes: 5 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ spec/spec_helper.rb:
unmanaged: false
.travis.yml:
delete: true
Rakefile:
extra_disabled_lint_checks:
- parameter_types
- params_empty_string_assignment
- unquoted_string_in_selector
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def changelog_future_release
end

PuppetLint.configuration.send('disable_relative')
PuppetLint.configuration.send('disable_parameter_types')
PuppetLint.configuration.send('disable_params_empty_string_assignment')
PuppetLint.configuration.send('disable_unquoted_string_in_selector')


if Bundler.rubygems.find_name('github_changelog_generator').any?
Expand Down
4 changes: 2 additions & 2 deletions examples/database_full.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
sqlserver::config{ 'MSSQLSERVER':
sqlserver::config { 'MSSQLSERVER':
admin_user => 'sa',
admin_pass => 'Pupp3t1@',
}
sqlserver::database{ 'testdb_full':
sqlserver::database { 'testdb_full':
instance => 'MSSQLSERVER',
containment => 'PARTIAL',
compatibility => 110,
Expand Down
6 changes: 3 additions & 3 deletions examples/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
$sapwd = 'Pupp3t1@'
$instance_name = 'MSSQLSERVER'

sqlserver_instance{ $instance_name:
sqlserver_instance { $instance_name:
source => 'E:/',
security_mode => 'SQL',
sa_pwd => $sapwd,
features => ['SQL'],
sql_sysadmin_accounts => ['vagrant'],
}

sqlserver::config{ 'MSSQLSERVER':
sqlserver::config { 'MSSQLSERVER':
admin_user => 'sa',
admin_pass => 'Pupp3t1@',
require => Mssql_instance[$instance_name],
}

sqlserver::login{ 'padmin':
sqlserver::login { 'padmin':
password => 'PadminP@ssw0rd1',
instance => $instance_name,
}
6 changes: 3 additions & 3 deletions examples/sp_configure.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
sqlserver::config{ 'MSSQLSERVER':
sqlserver::config { 'MSSQLSERVER':
admin_user => 'sa',
admin_pass => 'Pupp3t1@',
require => Mssql_instance[$instance_name],
}
#Enable Filestream access on server
sqlserver::sp_configure{ 'filestream access level':
sqlserver::sp_configure { 'filestream access level':
value => 1,
}
#Enable Partial Contained databases on server
sqlserver::sp_configure{ 'contained database authentication':
sqlserver::sp_configure { 'contained database authentication':
value => 1,
reconfigure => true,
with_override => false,
Expand Down
8 changes: 3 additions & 5 deletions lib/puppet_x/sqlserver/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ def self.get_reg_instance_info(friendly_version)

def self.get_sql_reg_key_features(key_name, reg_key_feat_hash, instance_name)
installed = reg_key_feat_hash.select do |subkey, _feat_name|
begin
open(HKLM, "#{key_name}\\#{subkey}", KEY_READ | KEY64) do |feat_key|
get_reg_key_val(feat_key, instance_name, Win32::Registry::REG_SZ)
end
rescue Puppet::Util::Windows::Error
open(HKLM, "#{key_name}\\#{subkey}", KEY_READ | KEY64) do |feat_key|
get_reg_key_val(feat_key, instance_name, Win32::Registry::REG_SZ)
end
rescue Puppet::Util::Windows::Error
end

installed.values
Expand Down
4 changes: 2 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# }
#
define sqlserver::config (
Optional[Variant[Sensitive[String], String]] $admin_user = '',
Optional[Variant[Sensitive[String], String]] $admin_pass = '',
Variant[Sensitive[String], String] $admin_user = '',
Variant[Sensitive[String], String] $admin_pass = '',
Enum['SQL_LOGIN', 'WINDOWS_LOGIN'] $admin_login_type = 'SQL_LOGIN',
String[1,16] $instance_name = $title,
) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
Integer[1753, 9999] $two_digit_year_cutoff = 2049,
Enum['ON', 'OFF'] $db_chaining = 'OFF',
Enum['ON', 'OFF'] $trustworthy = 'OFF',
){
) {
##
# validate max size
# Specifies that the file grows until the disk is full. In SQL Server, a log file specified with unlimited growth has
Expand Down
21 changes: 10 additions & 11 deletions manifests/login.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@
Enum['SQL_LOGIN', 'WINDOWS_LOGIN'] $login_type = 'SQL_LOGIN',
Enum['present', 'absent'] $ensure = 'present',
Optional[Variant[Sensitive[String], String]] $password = undef,
Optional[Hash] $svrroles = { },
Hash $svrroles = {},
String $default_database = 'master',
String $default_language = 'us_english',
Boolean $check_expiration = false,
Boolean $check_policy = true,
Boolean $disabled = false,
Optional[Hash] $permissions = { },
Hash $permissions = {},
) {

sqlserver_validate_instance_name($instance)

if $check_expiration and !$check_policy {
Expand All @@ -77,42 +76,42 @@
absent => 'delete',
}

sqlserver_tsql{ "login-${instance}-${login}":
sqlserver_tsql { "login-${instance}-${login}":
instance => $instance,
command => template("sqlserver/${_create_delete}/login.sql.erb"),
onlyif => template('sqlserver/query/login_exists.sql.erb'),
require => Sqlserver::Config[$instance]
require => Sqlserver::Config[$instance],
}

if $ensure == present {
$_upermissions = sqlserver_upcase($permissions)
sqlserver_validate_hash_uniq_values($_upermissions, "Duplicate permissions found for sqlserver::login[${title}]")

Sqlserver::Login::Permissions{
Sqlserver::Login::Permissions {
login => $login,
instance => $instance,
require => Sqlserver_tsql["login-${instance}-${login}"]
require => Sqlserver_tsql["login-${instance}-${login}"],
}
if has_key($_upermissions, 'GRANT') and is_array($_upermissions['GRANT']) {
sqlserver::login::permissions{ "Sqlserver::Login[${title}]-GRANT-${login}":
sqlserver::login::permissions { "Sqlserver::Login[${title}]-GRANT-${login}":
state => 'GRANT',
permissions => $_upermissions['GRANT'],
}
}
if has_key($_upermissions, 'DENY') and is_array($_upermissions['DENY']) {
sqlserver::login::permissions{ "Sqlserver::Login[${title}]-DENY-${login}":
sqlserver::login::permissions { "Sqlserver::Login[${title}]-DENY-${login}":
state => 'DENY',
permissions => $_upermissions['DENY'],
}
}
if has_key($_upermissions, 'REVOKE') and is_array($_upermissions['REVOKE']) {
sqlserver::login::permissions{ "Sqlserver::Login[${title}]-REVOKE-${login}":
sqlserver::login::permissions { "Sqlserver::Login[${title}]-REVOKE-${login}":
state => 'REVOKE',
permissions => $_upermissions['REVOKE'],
}
}
if has_key($_upermissions, 'GRANT_WITH_OPTION') and is_array($_upermissions['GRANT_WITH_OPTION']) {
sqlserver::login::permissions{ "Sqlserver::Login[${title}]-GRANT-WITH_GRANT_OPTION-${login}":
sqlserver::login::permissions { "Sqlserver::Login[${title}]-GRANT-WITH_GRANT_OPTION-${login}":
state => 'GRANT',
with_grant_option => true,
permissions => $_upermissions['GRANT_WITH_OPTION'],
Expand Down
8 changes: 4 additions & 4 deletions manifests/login/permissions.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
String[1,128] $login,
Array[String[4,128]] $permissions,
Pattern[/(?i)^(GRANT|REVOKE|DENY)$/] $state = 'GRANT',
Optional[Boolean] $with_grant_option = false,
String[1,16] $instance = 'MSSQLSERVER',
){
Boolean $with_grant_option = false,
String[1,16] $instance = 'MSSQLSERVER',
) {
sqlserver_validate_instance_name($instance)

$_state = upcase($state)
Expand All @@ -38,7 +38,7 @@
true => '-WITH_GRANT_OPTION',
default => ''
}
sqlserver_tsql{ "login-permission-${instance}-${login}-${_state}${_grant_option}":
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'),
Expand Down
36 changes: 18 additions & 18 deletions manifests/role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
# @param members_purge
# Whether we should purge any members not listed in the members parameter. Default: false
##
define sqlserver::role(
String[1,128] $role = $title,
String[1,16] $instance = 'MSSQLSERVER',
define sqlserver::role (
String[1,128] $role = $title,
String[1,16] $instance = 'MSSQLSERVER',
Enum['present', 'absent'] $ensure = 'present',
Optional[String] $authorization = undef,
Enum['SERVER', 'DATABASE'] $type = 'SERVER',
String[1,128] $database = 'master',
Optional[Hash] $permissions = { },
Array[String] $members = [],
Boolean $members_purge = false,
){
Optional[String] $authorization = undef,
Enum['SERVER', 'DATABASE'] $type = 'SERVER',
String[1,128] $database = 'master',
Hash $permissions = {},
Array[String] $members = [],
Boolean $members_purge = false,
) {
sqlserver_validate_instance_name($instance)

if $type == 'SERVER' and $database != 'master' {
Expand All @@ -63,7 +63,7 @@
# users. see MODULES-3355
$sqlserver_tsql_title = "role-${instance}-${database}-${role}"

sqlserver_tsql{ $sqlserver_tsql_title:
sqlserver_tsql { $sqlserver_tsql_title:
command => template("sqlserver/${_create_delete}/role.sql.erb"),
onlyif => template('sqlserver/query/role_exists.sql.erb'),
instance => $instance,
Expand All @@ -72,41 +72,41 @@
if $ensure == present {
$_upermissions = sqlserver_upcase($permissions)

Sqlserver::Role::Permissions{
Sqlserver::Role::Permissions {
role => $role,
instance => $instance,
database => $database,
type => $type,
require => Sqlserver_tsql[$sqlserver_tsql_title]
require => Sqlserver_tsql[$sqlserver_tsql_title],
}
if has_key($_upermissions, 'GRANT') and is_array($_upermissions['GRANT']) {
sqlserver::role::permissions{ "Sqlserver::Role[${title}]-GRANT-${role}":
sqlserver::role::permissions { "Sqlserver::Role[${title}]-GRANT-${role}":
state => 'GRANT',
permissions => $_upermissions['GRANT'],
}
}
if has_key($_upermissions, 'DENY') and is_array($_upermissions['DENY']) {
sqlserver::role::permissions{ "Sqlserver::Role[${title}]-DENY-${role}":
sqlserver::role::permissions { "Sqlserver::Role[${title}]-DENY-${role}":
state => 'DENY',
permissions => $_upermissions['DENY'],
}
}
if has_key($_upermissions, 'REVOKE') and is_array($_upermissions['REVOKE']) {
sqlserver::role::permissions{ "Sqlserver::Role[${title}]-REVOKE-${role}":
sqlserver::role::permissions { "Sqlserver::Role[${title}]-REVOKE-${role}":
state => 'REVOKE',
permissions => $_upermissions['REVOKE'],
}
}
if has_key($_upermissions, 'GRANT_WITH_OPTION') and is_array($_upermissions['GRANT_WITH_OPTION']) {
sqlserver::role::permissions{ "Sqlserver::Role[${title}]-GRANT-WITH_GRANT_OPTION-${role}":
sqlserver::role::permissions { "Sqlserver::Role[${title}]-GRANT-WITH_GRANT_OPTION-${role}":
state => 'GRANT',
with_grant_option => true,
permissions => $_upermissions['GRANT_WITH_OPTION'],
}
}

if size($members) > 0 or $members_purge == true {
sqlserver_tsql{ "${sqlserver_tsql_title}-members":
sqlserver_tsql { "${sqlserver_tsql_title}-members":
command => template('sqlserver/create/role/members.sql.erb'),
onlyif => template('sqlserver/query/role/member_exists.sql.erb'),
instance => $instance,
Expand Down
15 changes: 7 additions & 8 deletions manifests/role/permissions.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
String[1,128] $role,
Array[String[4,128]] $permissions,
Pattern[/(?i)^(GRANT|REVOKE|DENY)$/] $state = 'GRANT',
Optional[Boolean] $with_grant_option = false,
Enum['SERVER','DATABASE'] $type = 'SERVER',
String[1,128] $database = 'master',
String[1,16] $instance = 'MSSQLSERVER',
){
Boolean $with_grant_option = false,
Enum['SERVER','DATABASE'] $type = 'SERVER',
String[1,128] $database = 'master',
String[1,16] $instance = 'MSSQLSERVER',
) {
if size($permissions) < 1 {
warning("Received an empty set of permissions for ${title}, no further action will be taken")
} else{
} else {
sqlserver_validate_instance_name($instance)
$_state = upcase($state)

Expand All @@ -52,11 +52,10 @@
##
# Parameters required in template are _state, role, _upermissions, database, type, with_grant_option
##
sqlserver_tsql{ "role-permissions-${role}-${_state}${_grant_option}-${instance}-${database}":
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'),
}
}

}
8 changes: 4 additions & 4 deletions manifests/sp_configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Boolean $reconfigure = true,
Boolean $with_override = false,
Boolean $restart = false,
){
) {
sqlserver_validate_instance_name($instance)

$service_name = $instance ? {
Expand All @@ -44,14 +44,14 @@
Sqlserver_tsql["sp_configure-${instance}-${config_name}"] ~> Exec["restart-service-${service_name}-${config_name}"]
}

sqlserver_tsql{ "sp_configure-${instance}-${config_name}":
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'),
require => Sqlserver::Config[$instance]
require => Sqlserver::Config[$instance],
}

exec{"restart-service-${service_name}-${config_name}":
exec { "restart-service-${service_name}-${config_name}":
command => template('sqlserver/restart_service.ps1.erb'),
provider => powershell,
logoutput => true,
Expand Down
Loading