Microsoft loves Linux. But this wasn't always the case as host Saron Yitbarek will share in episodes 1 and 2 of Command Line Heroes, an original podcast from Red Hat airing January 16th, about the OS wars for the desktop and then the datacenter.
Yet, today, here we are talking about Microsoft's embrace of Linux. Nothing showcases this new approach forward than the growing relationship between Microsoft and Red Hat. In this post we're going to explore one aspect of that relationship--Microsoft SQL Server 2017 on Red Hat® Enterprise Linux®, Microsoft’s reference Linux platform. By using Ansible playbooks and roles to quickly deploy SQL Server, we get to take the best of these tools for a spin.
What is Ansible
Ansible is a simple, powerful, and agentless automation language that allows us to perform a task–like installing, configuring, and dropping in a database schema–within a matter of minutes. This Red Hat-sponsored community project is particularly powerful because of the strong support from our community and interest from our vendor partners, making it easy for teams of people like Linux and database admins to work together and get systems up quickly and ready for production.
If you’ve never used Ansible before, head to our Getting Started page or check out one of our free workshops. It’s easy to get started and learn how to start automating.
To make it easy for people to automate, we also host Ansible Galaxy, which provides easy access to roles—a more complex way to organize and structure your Ansible playbooks.
This playbook uses some common Ansible modules for configuring the base operating system, and then community modules for interacting with the MsSQL deployment after initialization.
How to install SQL Server 2017 on RHEL with Ansible
Today we’ll be looking at a role that I’ve created to install Microsoft SQL server on top of Red Hat Enterprise Linux 7, with the option of loading in a DB schema. To use this you’ll need:
- A Red Hat Enterprise Linux 7 system, configured with the appropriate repositories for RPM packages.
NOTE: I’ll be using a system from a Red Hat Certified Cloud Service Provider with preconfigured repos. If you’d like to run this locally or inside a private datacenter, you can sign up for a free Developer Subscription
- Ansible installed on your primary working system.
- The ability to SSH from your working system to your RHEL 7 system.
You’ll also want some basic familiarity with using Ansible playbooks and roles, so if you didn’t check out our Getting Started page or attend a workshop, do that first before continuing!
You can easily install my role by running the following from your Ansible system:
ansible-galaxy install kyleabenson.mssql
Or take a look at the full content online at https://github.com/kyleabenson/ansible-role-mssql
Once the role is installed, we can take a look at what these playbooks will do. Let’s first take a look at tasks/main.yml:
The really great thing about Ansible is that it’s written in YAML, so it’s really easy to see what each task is doing. There’s even flexibility for variable insertion, conditionals, and a few other tricks to make it easy to handle different environments.
We can see that this is the main playbook for installation. It handles the messy bits of configuration for us, including:
- Adding Microsoft specific repositories.
- Installing the necessary prerequisite packages.
- Running the MsSQL script.
- Enabling firewall settings when necessary.
- Making sure the services start persistently.
Let’s put together a simple playbook for calling our newly installed role:
After we’re performed the initial installation, we can create a new database pretty easily. I’m pulling a task from the roles ‘new_db.yml’ into this playbook for simplicity’s sake.
Let’s take a look at the following video which shows:
- Creating the playbook to call our Ansible role.
- Installing Microsoft SQL Server 2017.
- Creating a new database.
And just like that, we have a fully configured and ready MsSQL database. I’ve also created some playbooks in that role that make it easy to import an existing db schema, delete a db, and uninstall.
Ansible makes it incredibly easy to start automating some of our most time consuming tasks. Ansible also makes it easy to configure packages and services on Windows systems, and Azure as well.
If you’d like to see more about using Ansible to manage Windows, be sure to check out all of our Windows integrations.
That’s it for now. If you have feedback feel free to drop me a line on twitter @kyleabenson or file an issue on the GitHub Repo. Happy automating!
This post was sponsored by Command Line Heroes, an original podcast from Red Hat.
About the author
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit