Skip to content

Commit efa5655

Browse files
committed
(CAT-1939) Validation (DO NOT REVIEW)
1 parent 7a7837e commit efa5655

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ jobs:
112112
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
113113
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
114114
115+
- name: Start SSH session
116+
uses: luchihoratiu/debug-via-ssh@main
117+
with:
118+
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
119+
SSH_PASS: ${{ secrets.SSH_PASS }}
120+
115121
- name: Run acceptance tests
116122
run: |
117123
bundle exec rake 'litmus:acceptance:parallel'

manifests/concurrent_session_limit.pp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# A description of what this class does
2+
#
3+
# @summary A short summary of the purpose of this class
4+
#
5+
# @param instancename
6+
# The instance name you want to manage. Defaults to the $title when not defined explicitly.
7+
#
8+
# @param logonlogin
9+
# The password for the logon_trigger_login account
10+
#
11+
# @example
12+
# include database_configurations::sqlserver::concurrent_session_limit
13+
class sqlserver::concurrent_session_limit (
14+
String $instancename = 'MSSQLSERVER',
15+
String $logonlogin = 'thisisnotarealpassword'
16+
) {
17+
# V-79119 CAT II - Limit concurrent sessions
18+
sqlserver::login { 'logon_trigger_login':
19+
ensure => 'present',
20+
instance => 'MSSQLSERVER',
21+
password => $logonlogin,
22+
login_type => 'SQL_LOGIN',
23+
check_expiration => true,
24+
check_policy => true,
25+
disabled => true,
26+
permissions => { 'REVOKE' => ['CONNECT SQL'] },
27+
}
28+
29+
sqlserver::role { 'ServerRole':
30+
ensure => 'present',
31+
instance => $instancename,
32+
role => 'SL-ConnectTr',
33+
permissions => { 'GRANT' => ['CONNECT SQL', 'VIEW SERVER STATE'] },
34+
type => 'SERVER',
35+
members => ['logon_trigger_login'],
36+
#members_purge => true,
37+
require => Sqlserver::Login['logon_trigger_login'],
38+
}
39+
40+
sqlserver_tsql { 'create logon_trigger_login':
41+
command => epp('sqlserver/query/customer/create_logon_trigger.sql.epp'),
42+
onlyif => "IF NOT EXISTS (SELECT 1 from sys.server_triggers where name = 'connection_limit_trigger') THROW 50000, 'trignotfound', 10",
43+
require => Sqlserver::Role['ServerRole'],
44+
}
45+
}

metadata.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@
2121
{
2222
"operatingsystem": "Windows",
2323
"operatingsystemrelease": [
24-
"2012",
25-
"2012 R2",
26-
"2016",
27-
"2019",
28-
"2022"
24+
"2016"
2925
]
3026
}
3127
],
3228
"requirements": [
3329
{
3430
"name": "puppet",
35-
"version_requirement": ">=7.0.0 < 9.0.0"
31+
"version_requirement": ">=7.0.0 < 8.0.0"
3632
}
3733
],
3834
"tags": [
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE TRIGGER [connection_limit_trigger]
2+
ON ALL SERVER WITH EXECUTE AS 'logon_trigger_login'
3+
FOR LOGON
4+
AS
5+
BEGIN
6+
IF EXISTS (
7+
SELECT NULL
8+
FROM sys.dm_exec_sessions s
9+
WHERE is_user_process = 1 AND
10+
s.original_login_name = ORIGINAL_LOGIN()
11+
HAVING COUNT(*) > 5000
12+
)
13+
BEGIN
14+
DECLARE @original_login SYSNAME = ORIGINAL_LOGIN();
15+
RAISERROR ('Max concurrent logins exceeded for login ''%s''', 16, 1, @original_login) WITH LOG;
16+
ROLLBACK;
17+
END
18+
END;

0 commit comments

Comments
 (0)