ansible share image

In this article, I will show you how to install Microsoft SQL on a dedicated Red Hat Enterprise Linux 8 instance and pass the execution environment image while the Ansible playbook runs. We will also explore how using the automation content navigator is an efficient method for this installation.

5 steps to install Microsoft SQL on RHEL using automation content navigator

Before getting started, please make sure that you have installed the Red Hat Ansible Automation Platform on your machine. Otherwise, please refer to the previous article about the Ansible Automation Platform installation.

1. Setting up automation content navigator

The automation content navigator is a text-based user interface (TUI) tool for creating, reviewing, and troubleshooting Ansible content, including inventories, playbooks, and collections.

To run the automation content navigator on RHEL8, you must have superuser privileges, ansible-core, Python 3, and Podman installed.

Verify that Ansible Automation Platform is installed on your environment by running the following command:

​​​​​​​[redhat@redhat]$ ansible --version

You will see the following output verifying the installation and version:

ansible [core 2.13.3]

  config file = /etc/ansible/ansible.cfg

  configured module search path = ['/home/nagesh/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']

  ansible python module location = /usr/lib/python3.9/site-packages/ansible

  ansible collection location = /home/nagesh/.ansible/collections:/usr/share/ansible/collections

  executable location = /usr/bin/ansible

  python version = 3.9.14 [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]

  jinja version = 3.1.2

  libyaml = True

Next, install a Python package that will be used to install the automation content navigator.

sudo dnf install python3-pip

2. Install the automation content navigator

Install automation content navigator with the following command:

python3 -m pip install ansible-navigator --user

Add the installation path to the user’s shell initialization file and source it by entering the following:

echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.profile
source ~/.profile

3. Launch the automation content navigator

Launch the automation content navigator TUI by entering the following(Figure 1):

ansible-navigator
The automation content navigator TUI
Figure 1: The automation content navigator TUI.

4. Setting up the Ansible execution environment

Execution environments are Linux container images that help execute Ansible playbooks. Automation can now be built and deployed using Ansible execution environments instead of Python virtual environments. Unlike legacy virtual environments, execution environments are container images that make it possible to incorporate system-level dependencies and collection-based content. Each execution environment allows you to have a customized image to run jobs, and each of them contains only what you need when running the job, nothing more.

A registry service account must be created prior to completing any of the subsequent tasks. Create a service account by entering the following:

podman login registry.redhat.io
Username: {REGISTRY-SERVICE-ACCOUNT-USERNAME}
Password: {REGISTRY-SERVICE-ACCOUNT-PASSWORD}
Login Succeeded!

Container file:

​​​​​​​FROM registry.redhat.io/ansible-automation-platform-22/ee-29-rhel8:latest

RUN ansible-galaxy collection install microsoft.sql

Build an image by entering the following Podman command:

​​​​​​​podman build -t <image-name>

Before pushing, make sure you are logged in to your private container image registry using the podman login command. 

Push the image into the container image registry as follows:

​​​​​​​podman push <image-name>

5. Install Microsoft SQL Server

Using the ansible-navigator command, run the following playbook, and define the executive environment image by using the --eei flag.

Playbook: microsoft_sql_playbook.yaml.

---

- hosts: dev
  become: yes

  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: "123@Redhat"
    mssql_edition: Evaluation
    mssql_enable_sql_agent: true
    mssql_install_fts: true
    mssql_install_powershell: true
    mssql_tune_for_fua_storage: true

  roles:
    - microsoft.sql.server

Inventory file:

[dev]
<target host IP> 

Run the ansible-navigator command to execute with dependencies as follows:

ansible-navigator run -m stdout mssql-install.yaml -i inventory  --user ec2-user --key-file redhat  --eei quay.io/narathod/mssql-aap:0.2

The output:

TASK [microsoft.sql.server : Configure a listener for the  availability group] ***
skipping: [3.236.15.223]

TASK [microsoft.sql.server : Ensure the ansible_managed header in /var/opt/mssql/mssql.conf] ***
changed: [3.236.15.223]

RUNNING HANDLER [microsoft.sql.server : Restart the mssql-server service] ******
changed: [3.236.15.223]

TASK [microsoft.sql.server : Post-input SQL scripts to SQL Server] *************

PLAY RECAP *********************************************************************
3.236.15.223               : ok=39   changed=16   unreachable=0    failed=0    skipped=72   rescued=0    ignored=0   

Use automation to install databases on RHEL

This article demonstrated how you can use automation to install Microsoft SQL Server on RHEL 8 machines via the automation content navigator. You can use this method to install other databases such as MongoDB, PostgreSQL, and OracleDB by picking the Ansible role and playbooks for that database. The rest stays the same.

Get started with the Ansible Automation Platform by exploring interactive labs. Ansible Automation Platform is also available as a managed offering on Microsoft Azure and as a self-managed offering on AWS.

Last updated: August 29, 2023