Why deploy SQL Server on Linux using an Ansible playbook? The answer is that automation is a key aspect of modern IT operations, which is why we at Red Hat are delighted to announce that the deployment and configuration of Microsoft SQL Server on Red Hat Enterprise Linux (RHEL) can be easily automated using Ansible and corresponding RHEL system roles for SQL Server. You can deploy high availability (HA) solutions, including configuring Always On availability groups. Ansible scripts can automate the entire deployment process, reducing manual intervention and minimizing errors.
SQL Server 2022 has as of July 2024 been officially certified with RHEL 9, and is now Generally Available on Red Hat Ecosystem Catalog.
Sounds good—what do I need to do?
First off, you’ll need an Azure subscription to get this set up. If you don't have an Azure subscription, you can easily create a free account here. You will also need to create a new resource group using Azure CLI, which contains three Azure virtual machines (VMs).
The first VM, where you configure Ansible Core, is the controller node. On this node, you'll install the SQL Server system role.
The remaining VMs are the target machines, also known as managed nodes, for deploying and configuring SQL Server using the system role.
Installing Ansible Core
Starting with RHEL 8.x on Azure VMs, the ansible-core package can be installed from the pre-configured AppStream repository. You can install Ansible Core on the controller node using the following command:
sudo dnf install ansible-core
In RHEL 9, software installation is ensured by dnf
rather than yum
—however, Red Hat continues to support the usage of yum
for consistency with previous major versions of RHEL. If you type dnf
instead of yum
, the command works as expected because both are aliases for compatibility.
Although RHEL 8 and RHEL 9 are based on DNF, they are compatible with YUM used in RHEL 7.
For more information, see Managing software with the DNF tool and Package management with DNF/YUM in RHEL 9.
You can check whether the installation was successful with the following command:
ansible --version
Configuring passwordless SSH access between nodes
You will need to configure a Secure Shell (SSH) connection between the controller node and all managed nodes where the SQL Server is to be installed.
Installing the SQL Server system role
The Ansible system role is called ansible-collection-microsoft-sql
. On the controller node, run the following command to install the SQL Server system role:
sudo yum install ansible-collection-microsoft-sql
This command will install the SQL Server role to /usr/share/ansible/collections
:
-rw-r--r--. 1 user user 7592 Jul 2 20:22 FILES.json
-rw-r--r--. 1 user user 1053 Jul 2 20:22 LICENSE-server
-rw-r--r--. 1 user user 854 Jul 2 20:22 MANIFEST.json
-rw-r--r--. 1 user user 1278 Jul 2 20:22 README.md
drwxr-xr-x. 1 user user 20 Jul 2 20:22 roles
drwxr-xr-x. 1 user user 20 Jul 2 20:22 tests
Creating and configuring the Ansible playbook
After installing the system role, you'll need to create the SQL Server playbook YAML file. To understand the various role variables, refer to the documentation or the README.md
included with the SQL Server system role.
To learn more about the inventory creation and sample playbook.yaml to run in next command, refer to the "creating inventory and playbook section" in Deploy Always On Availability Groups (AG) on SQL Server RHEL based Azure VMs - The Ansible Way.
Deploying SQL Server on the managed nodes
To deploy SQL Server on managed nodes using the Ansible playbook, run the following command from the controller node:
sudo ansible-playbook -u user playbook.yaml
This process will begin the deployment.
Removing resources
If you're not going to continue using your Azure VMs, please remember to remove them. If you created the three VMs in a new resource group, you can remove all the resources inside that resource group using Azure CLI.
Background
Red Hat and Microsoft have partnered for almost a decade to engineer innovative and validated solutions to customers. One of the latest results of this collaboration has been the general availability of Microsoft SQL Server 2022 on Red Hat Enterprise Linux (RHEL) 9, a joint solution that was highlighted at the recent Red Hat Summit 2024 in Denver, Colorado.
SQL Server is highly adaptable and can be deployed in various configurations on RHEL, including containers, virtual guests, and bare-metal deployments using rpm packages. Microsoft SQL Server also integrates seamlessly with Azure Arc, enabling a unified management experience across hybrid and multi-cloud environments and simplifies operations and enhances visibility for SQL Server deployments in diverse infrastructure setups.
Your benefits from migrating to SQL 2022 on RHEL 9
With RHEL 7 reaching its End of Maintenance on June 30, 2024 and RHEL 8 being out of full support since May 31, 2024, customers should ensure that their mission critical data infrastructure remains up-to-date and secure.
For deploying SQL Server 2022 on RHEL 9, a system with a minimum of 2 cores and 2 GB of memory is required. However, for optimal performance, a system with 4 cores and 8 GB of memory is recommended. Additionally, ensure you have a minimum of 6 GB of disk space for the SQL Server installation. It is crucial to have a compatible file system, such as XFS or EXT4, for optimal storage management.
Migrating to SQL 2022 on top of RHEL 9 offers substantial business benefits, including cost reduction, simplified configuration and management of SQL Server workloads, and enhanced security. For organizations currently using CentOS Linux, transitioning to RHEL can provide a more robust and supported environment, ensuring better performance and reliability.
Where I can learn more about Red Hat Enterprise Linux 9 for SQL Server 2022?
Here are some links to get you started:
- Red Hat Enterprise Linux for Microsoft SQL Server
- Migrate your SQL Server workloads to Red Hat Enterprise Linux
- RHEL leads SQL Server deployments on Linux
- Get started with SQL on Linux
- Get started with Microsoft Fabric
- Stratis-managed file systems for SQL on RHEL
Try out Red Hat Enterprise Linux Server with our free trial.