Chapter 23. Configuring Microsoft SQL Server using the microsoft.sql.server Ansible role
As an administrator, you can use the microsoft.sql.server
Ansible role to install, configure, and start Microsoft SQL Server (SQL Server). The microsoft.sql.server
Ansible role optimizes your operating system to improve performance and throughput for the SQL Server. The role simplifies and automates the configuration of your RHEL host with recommended settings to run the SQL Server workloads.
23.1. Prerequisites
- 2 GB of RAM
-
root
access to the managed node where you want to configure SQL Server Pre-configured firewall
You can set the
mssql_manage_firewall
variable totrue
so that the role can manage firewall automatically.Alternatively, enable the connection on the SQL Server TCP port set with the
mssql_tcp_port
variable. If you do not define this variable, the role defaults to the TCP port number1433
.To add a new port, use:
# firewall-cmd --add-port=xxxx/tcp --permanent # firewall-cmd --reload
Replace xxxx with the TCP port number then reload the firewall rules.
-
Optional: Create a file with the
.sql
extension containing the SQL statements and procedures to input them to SQL Server.
23.2. Installing the microsoft.sql.server
Ansible role
The microsoft.sql.server
Ansible role is part of the ansible-collection-microsoft-sql
package.
Prerequisites
-
root
access
Procedure
Install Ansible Core which is available in the RHEL 7.9 AppStream repository:
# *yum install ansible-core*
Install the
microsoft.sql.server
Ansible role:# *yum install ansible-collection-microsoft-sql*
23.3. Installing and configuring SQL server using the microsoft.sql.server
Ansible role
You can use the microsoft.sql.server
Ansible role to install and configure SQL server.
Prerequisites
- The Ansible inventory is created
Procedure
-
Create a file with the
.yml
extension. For example,mssql-server.yml
. Add the following content to your
.yml
file:--- - hosts: all vars: mssql_accept_microsoft_odbc_driver_17_for_sql_server_eula: true mssql_accept_microsoft_cli_utilities_for_sql_server_eula: true mssql_accept_microsoft_sql_server_standard_eula: true mssql_password: <password> mssql_edition: Developer mssql_tcp_port: 1433 roles: - microsoft.sql.server
Replace <password> with your SQL Server password.
Run the
mssql-server.yml
ansible playbook:# *ansible-playbook mssql-server.yml*
23.4. TLS variables
You can use the following variables to configure the Transport Level Security (TLS) protocol.
Role variable | Description |
---|---|
mssql_tls_enable | This variable enables or disables TLS encryption.
The
When set to |
mssql_tls_cert | To define this variable, enter the path to the TLS certificate file. |
mssql_tls_private_key | To define this variable, enter the path to the private key file. |
mssql_tls_remote_src |
Defines if the role searches for
When set to the default
When set to |
mssql_tls_version | Define this variable to select which TSL version to use.
The default is |
mssql_tls_force |
Set this variable to
The default is |
23.5. Accepting EULA for MLServices
You must accept all the EULA for the open-source distributions of Python and R packages to install the required SQL Server Machine Learning Services (MLServices).
See /usr/share/doc/mssql-server
for the license terms.
Role variable | Description |
---|---|
mssql_accept_microsoft_sql_server_standard_eula |
This variable determines whether to accept the terms and conditions for installing the
To accept the terms and conditions set this variable to
The default is |
23.6. Accepting EULAs for Microsoft ODBC 17
You must accept all the EULAs to install the Microsoft Open Database Connectivity (ODBC) driver.
See /usr/share/doc/msodbcsql17/LICENSE.txt
and /usr/share/doc/mssql-tools/LICENSE.txt
for the license terms.
Role variable | Description |
---|---|
mssql_accept_microsoft_odbc_driver_17_for_sql_server_eula |
This variable determines whether to accept the terms and conditions for installing the
To accept the terms and conditions set this variable to
The default is |
mssql_accept_microsoft_cli_utilities_for_sql_server_eula |
This variable determines whether to accept the terms and conditions for installing the
To accept the terms and conditions set this variable to
The default is |
23.7. High availability variables
You can configure high availability for Microsoft SQL Server with the variables from the table below.
Variable | Description |
---|---|
|
The default value is
When it is set to
|
|
This variable specifies which type of replica you can configure on the host. You can set this variable to |
|
The default port is The role uses this TCP port to replicate data for an Always On availability group. |
| You must define the name of the certificate to secure transactions between members of an Always On availability group. |
| You must set the password for the master key to use with the certificate. |
| You must set the password for the private key to use with the certificate. |
|
The default value is
If it is set to |
| You must define the name of the endpoint to configure. |
| You must define the name of the availability group to configure. |
| You can define a list of the databases to replicate, otherwise the role creates a cluster without replicating databases. |
| The SQL Server Pacemaker resource agent utilizes this user to perform database health checks and manage state transitions from replica to primary server. |
|
The password for the |
|
The default value is
This variable defines if this role runs the
Note that the
To work around this limitation, the
If you want the |
Note, this role backs up the database to the /var/opt/mssql/data/
directory.
For examples on how to use high availability variables for Microsoft SQL Server:
-
If you install the role from Automation Hub, see the
~/.ansible/collections/ansible_collections/microsoft/sql/roles/server/README.md
file on your server. -
If you install the role from a package, open the
/usr/share/microsoft/sql-server/README.html
file in your browser.