Skip to content

(maint) Add more advanced examples to documentation #226

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 1 commit into from
Jun 26, 2017
Merged
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
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,81 @@ sqlserver_tsql{ 'Always running':
}
```

### Advanced Example

This advanced example will:

* Install the basic SQL Server Engine from installation media mounted at 'D:\' with TCP Enabled and various directories set.

* 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.

* 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.

* 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.

* Ensure that the advanced options for sp_configure are enabled so we can manage the Max Memory setting for the instance.

* Ensure that the Max Memory (MB) configuration item is set to 2048 megabytes.

```puppet
$sourceloc = 'D:/'

# Install a SQL Server default instance
sqlserver_instance{'MSSQLSERVER':
source => $sourceloc,
features => ['SQLEngine'],
sql_sysadmin_accounts => [$facts['id']],
install_switches => {
'TCPENABLED' => 1,
'SQLBACKUPDIR' => 'C:\\MSSQLSERVER\\backupdir',
'SQLTEMPDBDIR' => 'C:\\MSSQLSERVER\\tempdbdir',
'INSTALLSQLDATADIR' => 'C:\\MSSQLSERVER\\datadir',
'INSTANCEDIR' => 'C:\\Program Files\\Microsoft SQL Server',
'INSTALLSHAREDDIR' => 'C:\\Program Files\\Microsoft SQL Server',
'INSTALLSHAREDWOWDIR' => 'C:\\Program Files (x86)\\Microsoft SQL Server'
}
}

# Resource to connect to the DB instance
sqlserver::config { 'MSSQLSERVER':
admin_login_type => 'WINDOWS_LOGIN'
}

# Enforce SQL Server Administrators
$local_dba_group_name = 'DB Administrators'
$local_dba_group_netbios_name = "${facts['hostname']}\\DB Administrators"

group { $local_dba_group_name:
ensure => present
}

-> sqlserver::login { $local_dba_group_netbios_name :
login_type => 'WINDOWS_LOGIN',
}

-> sqlserver::role { 'sysadmin':
ensure => 'present',
instance => 'MSSQLSERVER',
type => 'SERVER',
members => [$local_dba_group_netbios_name, $facts['id']],
}

# Enforce memory consumption
sqlserver_tsql {'check advanced sp_configure':
command => 'EXEC sp_configure \'show advanced option\', \'1\'; RECONFIGURE;',
onlyif => 'sp_configure @configname=\'max server memory (MB)\'',
instance => 'MSSQLSERVER'
}

-> sqlserver::sp_configure { 'MSSQLSERVER-max memory':
config_name => 'max server memory (MB)',
instance => 'MSSQLSERVER',
reconfigure => true,
restart => true,
value => 2048
}
```

## Reference

### Types
Expand Down