Skip to content

Commit de65567

Browse files
committed
Added custom fact. Removed $domainNetbiosName class parameter. Used custom fact instead.
1 parent 6751057 commit de65567

9 files changed

Lines changed: 27 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- **BREAKING CHANGE** : Require puppetlabs/dsc compiled with SQLServerDSC = 10.0.0.0
55
- **BREAKING CHANGE** : Changed $sqlservicecredential_username and $sqlagentservicecredential_username format. User accounts now required **WITHOUT** Netbios Domain Name prefix.
66
- **BREAKING CHANGE** : Removed $domainName class parameter. Used facts instead.
7+
- **BREAKING CHANGE** : Removed $domainNetbiosName class parameter. Used custom fact instead.
78

89
## Version 1.1.0
910
- Initial release

README.markdown

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ The module can be installed on a Standard, Datacenter, or Core version of Window
2222
- **setupdir** : (string) Path of a folder containing the SQL Server installer (unarchive the ISO image in this folder).
2323
- **sa_password** : (string) SQL Server SA password for mixed mode SQL authentication configuration.
2424
- **productkey** : (string)(optionnal) Product key for licensed installations.
25-
- **sqlservicecredential_username** : (String) Service account for the SQL service **WITHOUT** Netbios Domain Name prefix
25+
- **sqlservicecredential_username** : (String) Domain service account for the SQL service **WITHOUT** Netbios Domain Name prefix. The account will be automatically created in Active Directory by the module. MSSQLSvc/fqdn_of_sql_server_node SPN will be associated with the service account.
2626
- **sqlservicecredential_password** : (String) : Password of the service account for the SQL service. Should be encrypted with hiera-eyaml.
27-
- **sqlagentservicecredential_username** : (String) Service account for the SQL Agent service **WITHOUT** Netbios Domain Name prefix
27+
- **sqlagentservicecredential_username** : (String) Domain service account for the SQL Agent service **WITHOUT** Netbios Domain Name prefix. The account will be automatically created in Active Directory by the module.
2828
- **sqlagentservicecredential_password** : (String) Password of the service account for the SQL Agent service. Should be encrypted with hiera-eyaml.
2929
- **sqladministratoraccounts** : (String[] Array) : Array of accounts to be made SQL administrators.
3030
- **sqluserdbdir** : (String)(optionnal) Path for SQL database files. Default to 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
@@ -37,7 +37,6 @@ The module can be installed on a Standard, Datacenter, or Core version of Window
3737
- **fileShareWitness** : (String) Fileshare witness UNC path in the format'\\witness.company.local\witness$'. Needs to be writable by SQL nodes.
3838
- **listenerIP** : (String) The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0.
3939
- **role** : (String) Needs to be 'primary' for primary SQL nodes or 'secondary' for SQL replica nodes
40-
- **domainNetbiosName** : (String) Active Directory domain NETBIOS name
4140

4241

4342
## Installing a Microsoft SQL Server AlwaysOn cluster
@@ -72,8 +71,7 @@ node 'SQL01' {
7271
clusterIP => '192.168.1.60',
7372
fileShareWitness=> '\\192.168.1.10\quorum',
7473
listenerIP => '192.168.1.61/255.255.255.0',
75-
role => 'primary',
76-
domainNetbiosName => 'DOMAIN-TEST'
74+
role => 'primary'
7775
}
7876
}
7977
@@ -94,8 +92,7 @@ node 'SQL02' {
9492
clusterIP => '192.168.1.60',
9593
fileShareWitness=> '\\192.168.1.10\quorum',
9694
listenerIP => '192.168.1.61/255.255.255.0',
97-
role => 'secondary',
98-
domainNetbiosName => 'DOMAIN-TEST'
95+
role => 'secondary'
9996
}
10097
}
10198

lib/facter/domainnetbiosname.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#https://puppet.com/blog/starting-out-writing-custom-facts-windows
2+
Facter.add('domainnetbiosname') do
3+
confine :osfamily => :windows
4+
setcode do
5+
begin
6+
require 'win32ole'
7+
wmi = WIN32OLE.connect("winmgmts:\\\\.\\root\\cimv2")
8+
win32ntdomain = wmi.ExecQuery("SELECT * FROM Win32_NTDomain").each.first
9+
win32ntdomain.DomainName
10+
rescue
11+
nil
12+
end
13+
end
14+
end

manifests/alwaysonconfig.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
dsc_servername => $hostname,
4444
dsc_instancename => 'MSSQLSERVER',
4545
dsc_name => 'HADR',
46-
dsc_principal => "${domainNetbiosName}\\$sqlservicecredential_username",
46+
dsc_principal => "${domainnetbiosname}\\$sqlservicecredential_username",
4747
dsc_permission => 'CONNECT',
4848
dsc_psdscrunascredential => {'user' => $setup_svc_username, 'password' => $setup_svc_password}
4949
}

manifests/config.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
dsc_ensure => 'Present',
2929
dsc_servername => $hostname,
3030
dsc_instancename => 'MSSQLSERVER',
31-
dsc_name => "${domainNetbiosName}\\Domain Admins",
31+
dsc_name => "${domainnetbiosname}\\Domain Admins",
3232
dsc_logintype => 'WindowsGroup',
3333
dsc_psdscrunascredential => {'user' => $setup_svc_username, 'password' => $setup_svc_password}
3434
}
3535

3636
dsc_sqlserverrole{'AddDomainAdminsSQLSysadmin':
3737
dsc_ensure => 'Present',
3838
dsc_serverrolename => 'sysadmin',
39-
dsc_memberstoinclude => "${domainNetbiosName}\\Domain Admins",
39+
dsc_memberstoinclude => "${domainnetbiosname}\\Domain Admins",
4040
dsc_servername => $hostname,
4141
dsc_instancename => 'MSSQLSERVER',
4242
require => Dsc_sqlserverlogin['DomainAdminsLogin'],
@@ -48,7 +48,7 @@
4848
dsc_ensure => 'Present',
4949
dsc_servername => $hostname,
5050
dsc_instancename => 'MSSQLSERVER',
51-
dsc_name => "${domainNetbiosName}\\$sqlservicecredential_username",
51+
dsc_name => "${domainnetbiosname}\\$sqlservicecredential_username",
5252
dsc_logintype => 'WindowsUser',
5353
dsc_psdscrunascredential => {'user' => $setup_svc_username, 'password' => $setup_svc_password}
5454
}

manifests/domainconfig.pp

Lines changed: 0 additions & 13 deletions
This file was deleted.

manifests/init.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
$fileShareWitness, #Format '\\witness.company.local\witness$'
3232
$listenerIP, #The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0.
3333
$role, ##primary or secondary
34-
$domainNetbiosName
3534
)
3635
{
3736
#Using $domain fact du get the active directory domain name

manifests/install.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
dsc_securitymode => 'SQL',
5454
dsc_sapwd => {'user' => 'sa', 'password' => $sa_password},
5555
dsc_productkey => $productkey,
56-
dsc_sqlsvcaccount => {'user' => "${domainNetbiosName}\\$sqlservicecredential_username", 'password' => $sqlservicecredential_password},
57-
dsc_agtsvcaccount => {'user' => "${domainNetbiosName}\\$sqlagentservicecredential_username", 'password' => $sqlagentservicecredential_password},
58-
dsc_assvcaccount => {'user' => "${domainNetbiosName}\\$sqlservicecredential_username", 'password' => $sqlservicecredential_password},
56+
dsc_sqlsvcaccount => {'user' => "${domainnetbiosname}\\$sqlservicecredential_username", 'password' => $sqlservicecredential_password},
57+
dsc_agtsvcaccount => {'user' => "${domainnetbiosname}\\$sqlagentservicecredential_username", 'password' => $sqlagentservicecredential_password},
58+
dsc_assvcaccount => {'user' => "${domainnetbiosname}\\$sqlservicecredential_username", 'password' => $sqlservicecredential_password},
5959
dsc_sqlsysadminaccounts => $sqladministratoraccounts,
6060
dsc_assysadminaccounts => $sqladministratoraccounts,
6161
dsc_installshareddir => 'C:\Program Files\Microsoft SQL Server',

manifests/serviceaccounts.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class sqlserveralwayson::serviceaccounts inherits sqlserveralwayson {
2+
23
#Needed for ActiveDirectory remote management using Powershell
34
dsc_windowsfeature{ 'RSAT-AD-Powershell':
45
dsc_ensure => 'Present',

0 commit comments

Comments
 (0)