Skip to content

Commit 04c4605

Browse files
authored
Merge pull request #226 from glennsarti/better-docs
(maint) Add more advanced examples to documentation
2 parents b596297 + ee738b3 commit 04c4605

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,81 @@ sqlserver_tsql{ 'Always running':
177177
}
178178
```
179179

180+
### Advanced Example
181+
182+
This advanced example will:
183+
184+
* Install the basic SQL Server Engine from installation media mounted at 'D:\' with TCP Enabled and various directories set.
185+
186+
* Uses only Windows based authentication and installs with only the user that Puppet is executing as. Note that the 'sql_sysadmin_accounts' is only applicable during the instance installation and is not actively enforced.
187+
188+
* Creates a sqlserver::config resource which is used in later resources to connect to the newly created instance. As we only support Windows based authentication , a username and password is not required.
189+
190+
* Create a local group called 'DB Administrators', and ensure that it is SQL System Administrator (sysadmin role) along with the account used to install the instance, and that Puppet uses to manage the database instance.
191+
192+
* Ensure that the advanced options for sp_configure are enabled so we can manage the Max Memory setting for the instance.
193+
194+
* Ensure that the Max Memory (MB) configuration item is set to 2048 megabytes.
195+
196+
```puppet
197+
$sourceloc = 'D:/'
198+
199+
# Install a SQL Server default instance
200+
sqlserver_instance{'MSSQLSERVER':
201+
source => $sourceloc,
202+
features => ['SQLEngine'],
203+
sql_sysadmin_accounts => [$facts['id']],
204+
install_switches => {
205+
'TCPENABLED' => 1,
206+
'SQLBACKUPDIR' => 'C:\\MSSQLSERVER\\backupdir',
207+
'SQLTEMPDBDIR' => 'C:\\MSSQLSERVER\\tempdbdir',
208+
'INSTALLSQLDATADIR' => 'C:\\MSSQLSERVER\\datadir',
209+
'INSTANCEDIR' => 'C:\\Program Files\\Microsoft SQL Server',
210+
'INSTALLSHAREDDIR' => 'C:\\Program Files\\Microsoft SQL Server',
211+
'INSTALLSHAREDWOWDIR' => 'C:\\Program Files (x86)\\Microsoft SQL Server'
212+
}
213+
}
214+
215+
# Resource to connect to the DB instance
216+
sqlserver::config { 'MSSQLSERVER':
217+
admin_login_type => 'WINDOWS_LOGIN'
218+
}
219+
220+
# Enforce SQL Server Administrators
221+
$local_dba_group_name = 'DB Administrators'
222+
$local_dba_group_netbios_name = "${facts['hostname']}\\DB Administrators"
223+
224+
group { $local_dba_group_name:
225+
ensure => present
226+
}
227+
228+
-> sqlserver::login { $local_dba_group_netbios_name :
229+
login_type => 'WINDOWS_LOGIN',
230+
}
231+
232+
-> sqlserver::role { 'sysadmin':
233+
ensure => 'present',
234+
instance => 'MSSQLSERVER',
235+
type => 'SERVER',
236+
members => [$local_dba_group_netbios_name, $facts['id']],
237+
}
238+
239+
# Enforce memory consumption
240+
sqlserver_tsql {'check advanced sp_configure':
241+
command => 'EXEC sp_configure \'show advanced option\', \'1\'; RECONFIGURE;',
242+
onlyif => 'sp_configure @configname=\'max server memory (MB)\'',
243+
instance => 'MSSQLSERVER'
244+
}
245+
246+
-> sqlserver::sp_configure { 'MSSQLSERVER-max memory':
247+
config_name => 'max server memory (MB)',
248+
instance => 'MSSQLSERVER',
249+
reconfigure => true,
250+
restart => true,
251+
value => 2048
252+
}
253+
```
254+
180255
## Reference
181256

182257
### Types

0 commit comments

Comments
 (0)