I am using Ansible to provision MS SQL Server 2017 to a CentOS 7.4 box. I first went through this guide via command line and it works, but my end goal is to "Ansible-ize" it. However, when I get to the step about installing the command line tools, the -y switch does not work for accepting the license.

[user@host ~]$ sudo yum install -y mssql-tools unixODBC-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0: will be installed
--> Processing Dependency: msodbcsql < for package: mssql-tools-
--> Processing Dependency: msodbcsql >= for package: mssql-tools-
---> Package unixODBC-devel.x86_64 0:2.3.1-11.el7 will be installed
--> Running transaction check
---> Package msodbcsql.x86_64 0: will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package          Arch     Version          Repository                     Size
 mssql-tools      x86_64       packages-microsoft-com-prod   249 k
 unixODBC-devel   x86_64   2.3.1-11.el7     pwbank_repo                    55 k
Installing for dependencies:
 msodbcsql        x86_64       packages-microsoft-com-prod   4.0 M

Transaction Summary
Install  2 Packages (+1 Dependent package)

Total size: 4.2 M
Installed size: 4.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
The license terms for this product can be downloaded from
https://aka.ms/odbc131eula and found in
/usr/share/doc/msodbcsql/LICENSE.TXT . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
  Installing : msodbcsql-                                  1/3 
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
  Installing : mssql-tools-                                2/3 
  Installing : unixODBC-devel-2.3.1-11.el7.x86_64                           3/3 
  Verifying  : msodbcsql-                                  1/3 
  Verifying  : unixODBC-devel-2.3.1-11.el7.x86_64                           2/3 
  Verifying  : mssql-tools-                                3/3 

  mssql-tools.x86_64 0:      unixODBC-devel.x86_64 0:2.3.1-11.el7     

Dependency Installed:
  msodbcsql.x86_64 0:                                                 


I noticed that there is a warning before I am prompted saying RPMDB altered outside of yum. Does this mean that Microsoft has specifically modified this rpm in their own way and, because of this, yum doesn't know how to handle it?

My Goal

Although the above works for a "by hand" install, I am trying to "ansible-ize" the above. My playbook works up until I get to this play:

- name: Upgrade all installed packages, and install new ones
    name: '{{item}}'
    state: latest
    - '*'
    - mssql-server
    - mssql-tools
    - unixODBC-devel

The above play will update all of my currently installed packages and install MS SQL Server 2017 just fine, but it will hang while trying to install the mssql-tools package, I assume because it is waiting for the user to accept the license.

My Question

How can I "ansible-ize" this install if my playbook hangs, waiting for the user to accept the license?

For bonus points, there's a step where I have to run sudo /opt/mssql/bin/mssql-conf setup and follow the on screen prompts which, again, impedes my provisioning. I am in the process of going through it once, finding its output file and seeing if I can't just copy that in whenever I re-provision a new box. Alternatively, I am in the process of reading up on Expect.

- name: install mssql-server repo (CentOS, RedHat)
    url: "{{ centos_repo_url }}"
    dest: /etc/yum.repos.d/mssql-server.repo
  when: ansible_distribution in ['CentOS', 'RedHat']

- name: install mssql-server repo (Ubuntu)
    url: "{{ ubuntu_repo_url }}"
    dest: /etc/apt/sources.list.d/mssql-server.list
  when: ansible_distribution == 'Ubuntu'

- name: refresh apt-get cache for server repo (Ubuntu)
  command: apt-get update
  when: ansible_distribution == 'Ubuntu'

- name: install mssql-server package
    name: mssql-server
    state: latest

- name: install mssql-tools package
    name: mssql-tools
    state: latest
    ACCEPT_EULA: 'y'

A sample playbook for installing and configuring SQL Server (along with creating a Pacemaker-managed Availability Group) is available at https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability/Linux/Ansible%20Playbook

| improve this answer | |

This should work in terms of EULA for Tools

sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev

As far as unattended install, you can specify environment variables or command line options for most things during setup. Take a look at Sample: Unattended SQL Server installation script for Red Hat Enterprise Linux.

NOTE: I noticed the repo in the links is still pointing to the older pre-RTM repo. Please use these repos while we correct them.

| improve this answer | |
  • 1
    I'm not using apt-get, I'm using yum. I'll try this in a bit here and let you know what I find. Thank you! – Nathan Smith Oct 3 '17 at 14:32
  • I just checked this way with yum and it works perfectly fine. Thanks! – Mariusz Oct 1 '19 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.