├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks └── main.yml └── vars └── main.yml /README.md: -------------------------------------------------------------------------------- 1 | kkolk.mssql 2 | ========= 3 | Description 4 | ----------- 5 | This ansible role will install a SQL Server Developer Edition 2017 instance on supported Windows platforms. This role can be adjusted to install any supported SQL server installation. I've used variants of it to install SQL Server 2012/2014. 6 | 7 | This role also handles local firewall changes as required and demonstrates how to make configuration adjustments to the SQL instance. 8 | 9 | Using default values it's designed to work as an role that can be added to the member server in the windows test environment I've laid out through a series of posts on http://frostbyte.us/configure-an-ansible-testing-system-on-windows-part-1/ 10 | 11 | Requirements 12 | ------------ 13 | 14 | Powershell 5.0 / WMF 5.1 should be installed on target host. 15 | 16 | You can do this in two steps with: 17 | 18 | ```yaml 19 | # The latest powershell gives us more flexiablity to use Windows DSC items 20 | - name: Windows | Install Powershell 5.0 21 | win_chocolatey: 22 | name: "powershell" 23 | register: check_powershell5 24 | become: yes 25 | become_user: Administrator 26 | become_method: runas 27 | retries: 3 28 | delay: 10 29 | 30 | # Powershell 5.0 requires a reboot, so lets get it done if it's needed. 31 | - name: Windows | Reboot to complete Powershell 5.0 install 32 | win_reboot: 33 | # We will give windows a full hour to reboot. 34 | reboot_timeout: 3600 35 | post_reboot_delay: 60 36 | when: check_powershell5.changed 37 | ``` 38 | 39 | Role Variables 40 | -------------- 41 | 42 | 43 | ```yaml 44 | # installation files source 45 | mssql_installation_source: https://go.microsoft.com/fwlink/?linkid=853016 46 | 47 | # Path to download installation media to 48 | mssql_installation_path: C:\SQLInstall 49 | 50 | # Temporary path to store downloader 51 | mssql_temp_download_path: C:\tmp 52 | 53 | # instance details 54 | mssql_instance_name: Test 55 | mssql_drive: C 56 | mssql_userdbvol_name: Userdbvol01 57 | mssql_port: 1433 58 | 59 | ### Memory Configuration ### 60 | # memory in MB 61 | # values must be divisible by 512 62 | 63 | # Max memory to allocate to this instance 64 | mssql_max_server_memory: 1024 65 | 66 | # Memory to reserve to the OS 67 | mssql_os_memory_reservation: 512 68 | 69 | # Total system memory 70 | mssql_total_system_memory: "{{ mssql_max_server_memory + mssql_os_memory_reservation }}" 71 | 72 | # Suppress reboots that may occur during SQL Setup tasks 73 | # you will want to set this to True if working on a sensitive system: 74 | mssql_suppress_reboot: False 75 | 76 | ### Service Accounts ### 77 | 78 | # SQL Service Account 79 | # regex statements used in some steps expect the format of CONTOSO\ 80 | # do not use @CONTOSO.com for these accounts as SQL install will fail 81 | mssql_sqlsvc_account: CONTOSO\sql_svc 82 | mssql_sqlsvc_account_pass: MyPlainTextPassWord01 83 | 84 | # SQL Agent Service Account 85 | mssql_agentsvc_account: CONTOSO\sql_agt 86 | mssql_agentsvc_account_pass: MyPlainTextPassWord01 87 | 88 | # SQL Analysis Services Account 89 | mssql_assvc_account: "{{ mssql_sqlsvc_account }}" 90 | mssql_assvc_account_pass: "{{ mssql_sqlsvc_account_pass }}" 91 | 92 | ### File and Folder Paths ### 93 | 94 | # volume paths 95 | mssql_userdbvol_path: "{{ mssql_drive }}:\\{{ mssql_userdbvol_name }}" 96 | mssql_db_accesspath: "{{ mssql_userdbvol_path }}\\DatabaseFiles" 97 | mssql_logs_accesspath: "{{ mssql_userdbvol_path }}\\DatabaseLogs" 98 | 99 | # shared files paths 100 | mssql_installshared_path: C:\Program Files\Microsoft SQL Server 101 | mssql_installsharedwow_path: C:\Program Files (x86)\Microsoft SQL Server 102 | 103 | # instance path 104 | mssql_instance_path: "C:\\Program Files\\Microsoft SQL Server\\{{ mssql_instance_name }}" 105 | 106 | # SQL DB and Logging Paths 107 | mssql_sqlinstalldata_path: "{{ mssql_db_accesspath }}\\{{mssql_instance_name }}" 108 | mssql_sqluserdata_path: "{{ mssql_db_accesspath }}\\{{mssql_instance_name }}" 109 | mssql_sqluserlog_path: "{{ mssql_logs_accesspath }}\\{{mssql_instance_name }}" 110 | mssql_sqltempDB_path: "C:\\TempDBFiles\\Data\\{{mssql_instance_name }}" 111 | mssql_sqltempDBlog_path: "C:\\TempDBFiles\\Log\\{{mssql_instance_name }}" 112 | 113 | # security mode - SQL indicates mixed-mode auth, while Windows indicates Windows Auth. 114 | mssql_security_mode: sql 115 | 116 | # SA user password, if security mode is set to 'SQL' 117 | # by default for testing we'll be lazy and use the service account password, 118 | # but on live systems you should use something else: 119 | mssql_sa_password: "{{ mssql_sqlsvc_account_pass }}" 120 | 121 | # features - Comma seperated list of features to be installed 122 | # 123 | # example: 124 | # mssql_features: SQLENGINE,AS 125 | # 126 | # The list of features below is untested, some may not work with DSC 127 | # 128 | # Features list: 129 | # 130 | # Database engine = SQLENGINE 131 | # Replication = REPLICATION 132 | # Full-text and semantic extractions for search = FULLTEXT 133 | # Data quality services = DQ 134 | # Analysis services = AS 135 | # Reporting services – native = RS 136 | # Reporting services – sharepoint = RS_SHP 137 | # Reporting services add-in for sharepoint products = RS_SHPWFE 138 | # Data quality client = DQC 139 | # SQL Server data tools = BIDS 140 | # Client tools connectivity = CONN 141 | # Integration services = IS 142 | # Client tools backwards compatibility = BC 143 | # Client tools SDK = SDK 144 | # Documentation components = BOL 145 | # Management tools – basic = SSMS 146 | # Management tools – advanced = ADV_SSMS 147 | # Distributed replay controller = DREPLAY_CTLR 148 | # Distributed replay client = DREPLAY_CLT 149 | # SQL client connectivity SDK = SNAC_SDK 150 | # Master data services = MDS 151 | # ADVANCEDANALYTICS Installs R Services, requires the database engine. Unattended installations require /IACCEPTROPENLICENSETERMS parameter. 152 | 153 | mssql_features: SQLENGINE,FULLTEXT,CONN 154 | 155 | # Collation 156 | mssql_collation: SQL_Latin1_General_CP1_CI_AS 157 | 158 | # Browser service startup mode 159 | # Specifies the startup mode for SQL Server Browser service. { Automatic | Disabled | 'Manual' } 160 | mssql_browsersvc_mode: Automatic 161 | 162 | # Default Account Access 163 | # Ansible_Admin must be included so that the playbook can make configuration changes post install 164 | mssql_sysadmin_accounts: 165 | - CONTOSO\Domain Admins 166 | - CONTOSO\Administrator 167 | 168 | # Analysis Services Admins (if installed) 169 | mssql_asadmin_accounts: "{{ mssql_sysadmin_accounts }}" 170 | 171 | # Tuning options 172 | 173 | # When an instance of SQL Server runs on a computer that has more than one microprocessor or CPU, 174 | # it detects the best degree of parallelism, that is, the number of processors employed to run a single statement, 175 | # for each parallel plan execution. You can use the max degree of parallelism option to limit the number of processors 176 | # to use in parallel plan execution. 177 | # 178 | # If the affinity mask option is not set to the default, it may restrict the number of processors available to 179 | # SQL Server on symmetric multiprocessing (SMP) systems. 180 | # 181 | # To enable the server to determine the maximum degree of parallelism, set this option to 0, the default value. 182 | # 183 | # See: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-max-degree-of-parallelism-server-configuration-option 184 | mssql_max_degree_of_parallelism: 0 185 | 186 | # Minimum memory to allocate to SQL 187 | # 188 | # Should remain 0 in most cases. 189 | # 190 | # see: Optimizing Server Performance Using Memory Configuration Options 191 | # https://technet.microsoft.com/en-us/library/ms177455(v=sql.105).aspx 192 | # 193 | # The min server memory server configuration option can be used to ensure that 194 | # SQL Server does not release memory below the configured minimum server memory 195 | # once that threshold is reached. This configuration option can be set to a specific value 196 | # based on the size and activity of your SQL Server. If you choose to set this value, 197 | # set it to some reasonable value to ensure that the operating system does not request too 198 | # much memory from SQL Server, which can affect SQL Server performance. 199 | mssql_min_server_memory: 0 200 | ``` 201 | 202 | Example Playbook 203 | ---------------- 204 | ```yaml 205 | - name: SQL Server 206 | hosts: sql_server 207 | tags: mssql 208 | 209 | roles: 210 | - { role: kkolk.mssql } 211 | ``` 212 | License 213 | ------- 214 | 215 | BSD / MIT 216 | 217 | Author Information 218 | ------------------ 219 | 220 | Kevin Kolk - http://www.frostbyte.us 221 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | # installation files source 2 | mssql_installation_source: https://go.microsoft.com/fwlink/?linkid=853016 3 | 4 | # Path to download installation media to 5 | mssql_installation_path: C:\SQLInstall 6 | 7 | # Temporary path to store downloader 8 | mssql_temp_download_path: C:\tmp 9 | 10 | # instance details 11 | mssql_instance_name: Test 12 | mssql_drive: C 13 | mssql_userdbvol_name: Userdbvol01 14 | mssql_port: 1433 15 | 16 | ### Memory Configuration ### 17 | # memory in MB 18 | # values must be divisible by 512 19 | 20 | # Max memory to allocate to this instance 21 | mssql_max_server_memory: 1024 22 | 23 | # Memory to reserve to the OS 24 | mssql_os_memory_reservation: 512 25 | 26 | # Total system memory 27 | mssql_total_system_memory: "{{ mssql_max_server_memory + mssql_os_memory_reservation }}" 28 | 29 | # Suppress reboots that may occur during SQL Setup tasks 30 | # you will want to set this to True if working on a sensitive system: 31 | mssql_suppress_reboot: False 32 | 33 | ### Service Accounts ### 34 | 35 | mssql_base_ldap_path: "cn=Users,dc=CONTOSO,dc=com" 36 | domain_controller: dc01 37 | 38 | # SQL Service Account 39 | # regex statements used in some steps expect the format of CONTOSO\ 40 | # do not use @CONTOSO.com for these accounts as SQL install will fail 41 | mssql_sqlsvc_account: CONTOSO\sql_svc 42 | mssql_sqlsvc_account_pass: MyPlainTextPassWord01 43 | 44 | # SQL Agent Service Account 45 | mssql_agentsvc_account: CONTOSO\sql_agt 46 | mssql_agentsvc_account_pass: MyPlainTextPassWord01 47 | 48 | # SQL Analysis Services Account 49 | mssql_assvc_account: "{{ mssql_sqlsvc_account }}" 50 | mssql_assvc_account_pass: "{{ mssql_sqlsvc_account_pass }}" 51 | 52 | ### File and Folder Paths ### 53 | 54 | # volume paths 55 | mssql_userdbvol_path: "{{ mssql_drive }}:\\{{ mssql_userdbvol_name }}" 56 | mssql_db_accesspath: "{{ mssql_userdbvol_path }}\\DatabaseFiles" 57 | mssql_logs_accesspath: "{{ mssql_userdbvol_path }}\\DatabaseLogs" 58 | 59 | # shared files paths 60 | mssql_installshared_path: C:\Program Files\Microsoft SQL Server 61 | mssql_installsharedwow_path: C:\Program Files (x86)\Microsoft SQL Server 62 | 63 | # instance path 64 | mssql_instance_path: "C:\\Program Files\\Microsoft SQL Server\\{{ mssql_instance_name }}" 65 | 66 | # SQL DB and Logging Paths 67 | mssql_sqlinstalldata_path: "{{ mssql_db_accesspath }}\\{{mssql_instance_name }}" 68 | mssql_sqluserdata_path: "{{ mssql_db_accesspath }}\\{{mssql_instance_name }}" 69 | mssql_sqluserlog_path: "{{ mssql_logs_accesspath }}\\{{mssql_instance_name }}" 70 | mssql_sqltempDB_path: "C:\\TempDBFiles\\Data\\{{mssql_instance_name }}" 71 | mssql_sqltempDBlog_path: "C:\\TempDBFiles\\Log\\{{mssql_instance_name }}" 72 | 73 | # security mode - SQL indicates mixed-mode auth, while Windows indicates Windows Auth. 74 | mssql_security_mode: sql 75 | 76 | # SA user password, if security mode is set to 'SQL' 77 | # by default for testing we'll be lazy and use the service account password, 78 | # but on live systems you should use something else: 79 | mssql_sa_password: "{{ mssql_sqlsvc_account_pass }}" 80 | 81 | # features - Comma seperated list of features to be installed 82 | # 83 | # example: 84 | # mssql_features: SQLENGINE,AS 85 | # 86 | # The list of features below is untested, some may not work with DSC 87 | # 88 | # Features list: 89 | # 90 | # Database engine = SQLENGINE 91 | # Replication = REPLICATION 92 | # Full-text and semantic extractions for search = FULLTEXT 93 | # Data quality services = DQ 94 | # Analysis services = AS 95 | # Reporting services – native = RS 96 | # Reporting services – sharepoint = RS_SHP 97 | # Reporting services add-in for sharepoint products = RS_SHPWFE 98 | # Data quality client = DQC 99 | # SQL Server data tools = BIDS 100 | # Client tools connectivity = CONN 101 | # Integration services = IS 102 | # Client tools backwards compatibility = BC 103 | # Client tools SDK = SDK 104 | # Documentation components = BOL 105 | # Management tools – basic = SSMS 106 | # Management tools – advanced = ADV_SSMS 107 | # Distributed replay controller = DREPLAY_CTLR 108 | # Distributed replay client = DREPLAY_CLT 109 | # SQL client connectivity SDK = SNAC_SDK 110 | # Master data services = MDS 111 | # ADVANCEDANALYTICS Installs R Services, requires the database engine. Unattended installations require /IACCEPTROPENLICENSETERMS parameter. 112 | 113 | mssql_features: SQLENGINE,FULLTEXT,CONN 114 | 115 | # Collation 116 | mssql_collation: SQL_Latin1_General_CP1_CI_AS 117 | 118 | # Browser service startup mode 119 | # Specifies the startup mode for SQL Server Browser service. { Automatic | Disabled | 'Manual' } 120 | mssql_browsersvc_mode: Automatic 121 | 122 | # Default Account Access 123 | # Ansible_Admin must be included so that the playbook can make configuration changes post install 124 | mssql_sysadmin_accounts: 125 | - CONTOSO\Domain Admins 126 | - CONTOSO\Administrator 127 | 128 | # Analysis Services Admins (if installed) 129 | mssql_asadmin_accounts: "{{ mssql_sysadmin_accounts }}" 130 | 131 | # Tuning options 132 | 133 | # When an instance of SQL Server runs on a computer that has more than one microprocessor or CPU, 134 | # it detects the best degree of parallelism, that is, the number of processors employed to run a single statement, 135 | # for each parallel plan execution. You can use the max degree of parallelism option to limit the number of processors 136 | # to use in parallel plan execution. 137 | # 138 | # If the affinity mask option is not set to the default, it may restrict the number of processors available to 139 | # SQL Server on symmetric multiprocessing (SMP) systems. 140 | # 141 | # To enable the server to determine the maximum degree of parallelism, set this option to 0, the default value. 142 | # 143 | # See: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-max-degree-of-parallelism-server-configuration-option 144 | mssql_max_degree_of_parallelism: 0 145 | 146 | # Minimum memory to allocate to SQL 147 | # 148 | # Should remain 0 in most cases. 149 | # 150 | # see: Optimizing Server Performance Using Memory Configuration Options 151 | # https://technet.microsoft.com/en-us/library/ms177455(v=sql.105).aspx 152 | # 153 | # The min server memory server configuration option can be used to ensure that 154 | # SQL Server does not release memory below the configured minimum server memory 155 | # once that threshold is reached. This configuration option can be set to a specific value 156 | # based on the size and activity of your SQL Server. If you choose to set this value, 157 | # set it to some reasonable value to ensure that the operating system does not request too 158 | # much memory from SQL Server, which can affect SQL Server performance. 159 | mssql_min_server_memory: 0 -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for roles/mssql 3 | - name: reboot windows 4 | win_reboot: 5 | reboot_timeout: 3600 6 | post_reboot_delay: 60 7 | when: mssql_suppress_reboot == False 8 | 9 | - name: restart sqlagent 10 | win_service: 11 | name: "SQLAgent${{ mssql_instance_name|upper }}" 12 | state: restarted -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: Kevin Kolk 3 | 4 | # If the issue tracker for your role is not on github, uncomment the 5 | # next line and provide a value 6 | # issue_tracker_url: http://example.com/issue/tracker 7 | 8 | # Some suggested licenses: 9 | # - BSD (default) 10 | # - MIT 11 | # - GPLv2 12 | # - GPLv3 13 | # - Apache 14 | # - CC-BY 15 | license: MIT / BSD 16 | 17 | min_ansible_version: 2.2 18 | 19 | # If this a Container Enabled role, provide the minimum Ansible Container version. 20 | # min_ansible_container_version: 21 | 22 | # Optionally specify the branch Galaxy will use when accessing the GitHub 23 | # repo for this role. During role install, if no tags are available, 24 | # Galaxy will use this branch. During import Galaxy will access files on 25 | # this branch. If Travis integration is configured, only notifications for this 26 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 27 | # (usually master) will be used. 28 | #github_branch: 29 | 30 | # 31 | # platforms is a list of platforms, and each platform has a name and a list of versions. 32 | # 33 | platforms: 34 | - name: Windows 35 | # versions: 36 | # - all 37 | # - 25 38 | # - name: SomePlatform 39 | # versions: 40 | # - all 41 | # - 1.0 42 | # - 7 43 | # - 99.99 44 | 45 | galaxy_tags: 46 | - MSSQL 47 | - SQL 48 | - Windows 49 | # List tags for your role here, one per line. A tag is a keyword that describes 50 | # and categorizes the role. Users find roles by searching for tags. Be sure to 51 | # remove the '[]' above, if you add tags to this list. 52 | # 53 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 54 | # Maximum 20 tags per role. 55 | 56 | dependencies: [] 57 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 58 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Install SQL Developer Edition 4 | # 5 | 6 | # Load required powershell modules 7 | - name: Powershell | Check for SQLServer DSC Powershell module 8 | win_psmodule: 9 | name: SQLServerDsc 10 | state: present 11 | 12 | - name: Powershell | Check for Storage DSC Powershell module 13 | win_psmodule: 14 | name: StorageDsc 15 | state: present 16 | 17 | - name: Powershell | Check for ServerManager Powershell module 18 | win_psmodule: 19 | name: ServerManager 20 | state: present 21 | 22 | - name: Powershell | Ensure that DBA Tools module is present 23 | win_psmodule: 24 | name: dbatools 25 | state: present 26 | 27 | - name: Powershell | Check for xNetworking Powershell module 28 | win_psmodule: 29 | name: xNetworking 30 | state: present 31 | 32 | - name: Windows | Install .NET Framework Core 33 | win_feature: 34 | name: NET-Framework-Core 35 | state: present 36 | 37 | # Setup SQL Server Pre-Reqs 38 | - name: Windows | Install .NET Framework 3.5 39 | win_feature: 40 | name: NET-Framework-Features 41 | state: present 42 | 43 | - name: Windows | Install .NET Framework 4.5 Features 44 | win_feature: 45 | name: NET-Framework-45-Features 46 | state: present 47 | include_sub_features: True 48 | 49 | - name: Windows | Install Windows Process Activation Service 50 | win_feature: 51 | name: WAS 52 | state: present 53 | include_sub_features: True 54 | 55 | # Setup service accounts 56 | # 57 | # We delegate this process to our domain controller since the required AD services are there for 58 | # win_domain_user to interact with. 59 | - name: Active Directory | Ensure SQL Service account is present 60 | win_domain_user: 61 | name: "{{ mssql_sqlsvc_account | regex_search('[^\\\\]*$') }}" 62 | firstname: "{{ mssql_instance_name }}" 63 | surname: SQLSvc 64 | password: "{{ mssql_sqlsvc_account_pass }}" 65 | password_never_expires: yes 66 | user_cannot_change_password: yes 67 | description: "SQL Service account for {{ inventory_hostname }}\\{{ mssql_instance_name }}" 68 | state: present 69 | path: "{{ mssql_base_ldap_path }}" 70 | groups: 71 | - Domain Users 72 | tags: service_account 73 | delegate_to: "{{ domain_controller }}" 74 | 75 | - name: Active Directory | Ensure SQL Agent Service account is present 76 | win_domain_user: 77 | name: "{{ mssql_agentsvc_account | regex_search('[^\\\\]*$') }}" 78 | firstname: "{{ mssql_instance_name }}" 79 | surname: AgentSvc 80 | password: "{{ mssql_agentsvc_account_pass }}" 81 | password_never_expires: yes 82 | user_cannot_change_password: yes 83 | description: "SQL Agent service account for {{ inventory_hostname }}\\{{ mssql_instance_name }}" 84 | state: present 85 | path: "{{ mssql_base_ldap_path }}" 86 | groups: 87 | - Domain Users 88 | delegate_to: "{{ domain_controller }}" 89 | tags: service_account 90 | 91 | # SQL install may fail if a pending reboot is detected 92 | # Assuming we are allowed to reboot this step will check for pending reboots 93 | # and execute a reboot, reboot activity can be controlled using the variable mssql_suppress_reboot 94 | 95 | - name: Ensure that a reboot is not pending 96 | when: ansible_reboot_pending 97 | debug: 98 | msg: 'Pending reboot detected' 99 | changed_when: true 100 | notify: reboot windows 101 | 102 | - meta: flush_handlers 103 | 104 | - name: Fetch SQL Media Downloader 105 | win_get_url: 106 | url: "{{ mssql_installation_source }}" 107 | dest: "{{ mssql_temp_download_path }}\\SQLServer2017-SSEI-Dev.exe" 108 | 109 | - name: Use Media Downloader to fetch SQL Installation CABs to {{ mssql_installation_path }} 110 | win_shell: "{{ mssql_temp_download_path }}\\SQLServer2017-SSEI-Dev.exe /Action=Download /MediaPath={{ mssql_installation_path }} /MediaType=CAB /Quiet" 111 | 112 | # Job will fail if extracted media folder is not empty, quick step to ensure it's empty 113 | - name: Ensure installation media extraction path is empty 114 | win_file: 115 | path: "{{ mssql_installation_path }}\\Media" 116 | state: absent 117 | 118 | - name: Extract installation media 119 | win_shell: "{{ mssql_installation_path }}\\SQLServer2017-DEV-x64-ENU.exe /X:{{ mssql_installation_path }}\\Media /Q" 120 | # If this step fails, logs are in C:\Program Files\Microsoft SQL Server\...\Setup Bootstrap\Log 121 | # it will often contain the actual error. If it shows everything passing, the issue is within the DSC logs. 122 | # 123 | # This module also typically throws this error fpr all failure conditions: 124 | # PowerShell DSC resource MSFT_SqlSetup failed to execute Set-TargetResource functionality with error message: 125 | # System.Exception: Test-TargetResource returned false after calling Set-TargetResource. 126 | # 127 | # 128 | # This document can also be useful to troubleshoot issues with DSC modules 129 | # https://docs.microsoft.com/en-us/powershell/dsc/troubleshooting 130 | # 131 | # In particular completing these steps: 132 | # https://docs.microsoft.com/en-us/powershell/dsc/troubleshooting#gathering-events-from-a-single-dsc-operation 133 | # then re-running a failing PowershellDSC job can help you find the source of your error 134 | - name: Install SQL Server 135 | win_dsc: 136 | resource_name: SQLSetup 137 | Action: Install 138 | UpdateEnabled: True 139 | SourcePath: "{{ mssql_installation_path }}\\Media" 140 | InstanceName: "{{ mssql_instance_name }}" 141 | InstallSharedDir: "{{ mssql_installshared_path }}" 142 | InstallSharedwowDir: "{{ mssql_installsharedwow_path }}" 143 | InstanceDir: "{{ mssql_instance_path }}" 144 | InstallSQLDataDir: "{{ mssql_sqlinstalldata_path }}" 145 | SQLUserDBDir: "{{ mssql_sqluserdata_path }}" 146 | SQLUserDBLogDir: "{{ mssql_sqluserlog_path }}" 147 | SQLTempDBDir: "{{ mssql_sqltempDB_path }}" 148 | SQLTempDBLogDir: "{{ mssql_sqltempDBlog_path }}" 149 | Features: "{{ mssql_features }}" 150 | SQLCollation: "{{ mssql_collation }}" 151 | BrowserSvcStartupType: "{{ mssql_browsersvc_mode }}" 152 | SuppressReboot: "{{ mssql_suppress_reboot }}" 153 | # Service Accounts 154 | # 155 | # If the type of the DSC resource option is a PSCredential then 156 | # there needs to be 2 options set in the Ansible task definition 157 | # suffixed with _username and _password. So we will be providing 158 | # two options for these normally single option items. 159 | 160 | # SQL Service Account 161 | SQLSvcAccount_username: "{{ mssql_sqlsvc_account }}" 162 | SQLSvcAccount_password: "{{ mssql_sqlsvc_account_pass }}" 163 | # SQL Agent Service Account 164 | AgtSvcAccount_username: "{{ mssql_agentsvc_account }}" 165 | AgtSvcAccount_password: "{{ mssql_agentsvc_account_pass }}" 166 | # SQL Analysis Services Account 167 | ASSvcAccount_username: "{{ mssql_assvc_account }}" 168 | ASSvcAccount_password: "{{ mssql_assvc_account_pass }}" 169 | 170 | # Used when installing on a network path, comment out 171 | # SourceCredential_username: "{{ ansible_user }}" 172 | # SourceCredential_password: "{{ ansible_password }}" 173 | 174 | # System Admins 175 | SQLSysAdminAccounts: "{{ mssql_sysadmin_accounts }}" 176 | # Analysis Services Admins (if installed) 177 | ASSysAdminAccounts: "{{ mssql_asadmin_accounts }}" 178 | tags: install_sql 179 | 180 | # End of win_dsc for SQL Server 181 | 182 | # Firewall configuration 183 | - name: Firewall | Allow Database Engine for instance 184 | win_dsc: 185 | resource_name: xFirewall 186 | Name: "SQL Server Database Engine instance {{ mssql_instance_name }}" 187 | Program: sqlservr.exe 188 | Ensure: present 189 | Enabled: True 190 | Profile: "Domain" 191 | Direction: "Inbound" 192 | Action: Allow 193 | Description: "Allows the Database Engine to access the network" 194 | tags: configure_firewall 195 | 196 | - name: Firewall | Allow SQLBrowser for instance 197 | win_dsc: 198 | resource_name: xFirewall 199 | Name: "SQL Server Browser instance {{ mssql_instance_name }}" 200 | Service: SQLBrowser 201 | Ensure: present 202 | Enabled: True 203 | Profile: "Domain" 204 | Direction: "Inbound" 205 | Action: Allow 206 | Description: "Allows the SQL Server Browser to access the network" 207 | tags: configure_firewall 208 | 209 | # Begin SQL Server configuration 210 | - name: Enable TCP Connectivity 211 | win_dsc: 212 | resource_name: SqlServerNetwork 213 | InstanceName: "{{ mssql_instance_name }}" 214 | ProtocolName: tcp 215 | TcpPort: "{{ mssql_port }}" 216 | IsEnabled: True 217 | RestartService: True 218 | tags: configure_sql 219 | 220 | - name: Adjust Max Server Memory to {{ mssql_max_server_memory }} 221 | when: mssql_max_server_memory is defined 222 | win_dsc: 223 | resource_name: SqlServerConfiguration 224 | InstanceName: "{{ mssql_instance_name }}" 225 | ServerName: "{{ ansible_hostname }}" 226 | OptionName: max server memory (MB) 227 | OptionValue: "{{ mssql_max_server_memory }}" 228 | RestartService: False 229 | tags: configure_sql 230 | 231 | - name: Adjust Min Server Memory to {{ mssql_min_server_memory }} 232 | when: mssql_min_server_memory is defined 233 | win_dsc: 234 | resource_name: SqlServerConfiguration 235 | ServerName: "{{ ansible_hostname }}" 236 | InstanceName: "{{ mssql_instance_name }}" 237 | OptionName: min server memory (MB) 238 | OptionValue: "{{ mssql_min_server_memory }}" 239 | tags: configure_sql 240 | 241 | - name: Adjust Max Degree of Parallelism 242 | when: mssql_max_degree_of_parallelism is defined 243 | win_dsc: 244 | resource_name: SqlServerConfiguration 245 | ServerName: "{{ ansible_hostname }}" 246 | InstanceName: "{{ mssql_instance_name }}" 247 | OptionName: max degree of parallelism 248 | OptionValue: "{{ mssql_max_degree_of_parallelism }}" 249 | tags: configure_sql -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for roles/mssql --------------------------------------------------------------------------------