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:14.0.6.0-1 will be installed
--> Processing Dependency: msodbcsql < 13.2.0.0 for package: mssql-tools-14.0.6.0-1.x86_64
--> Processing Dependency: msodbcsql >= 13.1.0.0 for package: mssql-tools-14.0.6.0-1.x86_64
---> Package unixODBC-devel.x86_64 0:2.3.1-11.el7 will be installed
--> Running transaction check
---> Package msodbcsql.x86_64 0:13.1.9.1-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mssql-tools x86_64 14.0.6.0-1 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 13.1.9.1-1 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)
YES
Installing : msodbcsql-13.1.9.1-1.x86_64 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)
YES
Installing : mssql-tools-14.0.6.0-1.x86_64 2/3
Installing : unixODBC-devel-2.3.1-11.el7.x86_64 3/3
Verifying : msodbcsql-13.1.9.1-1.x86_64 1/3
Verifying : unixODBC-devel-2.3.1-11.el7.x86_64 2/3
Verifying : mssql-tools-14.0.6.0-1.x86_64 3/3
Installed:
mssql-tools.x86_64 0:14.0.6.0-1 unixODBC-devel.x86_64 0:2.3.1-11.el7
Dependency Installed:
msodbcsql.x86_64 0:13.1.9.1-1
Complete!
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
package:
name: '{{item}}'
state: latest
with_items:
- '*'
- 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.
Best Answer
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