订阅内容

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:

  1. Creating the playbook to call our Ansible role.
  2. Installing Microsoft SQL Server 2017.
  3. 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!

CLH-MonitorGlow-Horizontal

This post was sponsored by Command Line Heroes, an original podcast from Red Hat.


关于作者

UI_Icon-Red_Hat-Close-A-Black-RGB

按频道浏览

automation icon

自动化

有关技术、团队和环境 IT 自动化的最新信息

AI icon

人工智能

平台更新使客户可以在任何地方运行人工智能工作负载

open hybrid cloud icon

开放混合云

了解我们如何利用混合云构建更灵活的未来

security icon

安全防护

有关我们如何跨环境和技术减少风险的最新信息

edge icon

边缘计算

简化边缘运维的平台更新

Infrastructure icon

基础架构

全球领先企业 Linux 平台的最新动态

application development icon

应用领域

我们针对最严峻的应用挑战的解决方案

Original series icon

原创节目

关于企业技术领域的创客和领导者们有趣的故事