Skip to content

Commit 9734131

Browse files
committed
(MODULES-3355) Fix Role Name Collisions
If sqlserver::role is specified more than one for the same role non-unique titles will be generated for the sqlserver_tsql that will handle the operations. This is likely to happen if setting up heira configs like this: 'sqlserver::role': ‘User_1’: role: db_owner database: FooBar instance: MSSQLSERVER members: - ‘User_1’ type: 'DATABASE' ‘User_2’: role: db_owner database: Wakka instance: MSSQLSERVER members: - ‘User_2’ type: 'DATABASE' This fix introduces the database name into the title created for the sqlserver_tsql statements so that it is unique.
1 parent 9f7004e commit 9734131

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

manifests/role.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
absent => 'delete',
6363
}
6464

65-
sqlserver_tsql{ "role-${role}-${instance}":
65+
sqlserver_tsql{ "role-${instance}-${database}-${role}":
6666
command => template("sqlserver/${_create_delete}/role.sql.erb"),
6767
onlyif => template('sqlserver/query/role_exists.sql.erb'),
6868
instance => $instance,

spec/defines/role_spec.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
RSpec.describe 'sqlserver::role', :type => :define do
55
include_context 'manifests' do
6-
let(:sqlserver_tsql_title) { 'role-myCustomRole-MSSQLSERVER' }
6+
let(:sqlserver_tsql_title) { 'role-MSSQLSERVER-master-myCustomRole' }
77
let(:title) { 'myCustomRole' }
88
end
99

@@ -54,6 +54,7 @@
5454
let(:additional_params) { {
5555
'database' => 'myCrazyDb',
5656
} }
57+
let(:sqlserver_tsql_title) { 'role-MSSQLSERVER-myCrazyDb-myCustomRole' }
5758
describe 'with server role type' do
5859
let(:raise_error_check) { 'Can not specify a database other than master when managing SERVER ROLES' }
5960
it_behaves_like 'validation error'
@@ -74,7 +75,7 @@
7475
describe 'non default instance' do
7576
let(:params) { {:instance => 'MYCUSTOM'} }
7677
it {
77-
should contain_sqlserver_tsql('role-myCustomRole-MYCUSTOM').with_instance('MYCUSTOM')
78+
should contain_sqlserver_tsql('role-MYCUSTOM-master-myCustomRole').with_instance('MYCUSTOM')
7879
}
7980
end
8081
describe 'empty instance' do

0 commit comments

Comments
 (0)