Installing the Microsoft ODBC Driver for SQL Server on Debian Linux with Saltstack

Installing the Microsoft ODBC Driver for SQL Server on Debian Linux (msodbcsql17) with Saltstack requires to pass ACCEPT_EULA=Y to the package manager. This blog post shows a possible solution.

Do you accept the license terms?


Microsoft offers several open source utilities for quite some time now. One is the Microsoft ODBC Driver for SQL Server on Linux which can be leveraged with unixodbc. In my case, I need this driver to query Microsoft SQL Server for my Zabbix ODBC monitoring, to execute native SQL queries for monitoring purposes. As I have to take control over 30+ Zabbix Proxies, I’m currently transforming all of them into Salt minions. My goal here is to achieve 100% automation, as soon as I install the Salt minion on a fresh Debian Linux.

The problem

In Saltstack the state declaration to install a package through the default package manager is straight forward:

Sadly the SQL driver requires an EULA to be accepted, which you can see when installing manually via: apt install msodbcsql17

Do you accept the license terms?
Do you accept the license terms?

To squeeze this into configuration management automation via Saltstack, Chef, Puppet or Ansible, there also is a request at Microsoft, which hasn’t been solved yet:

To give this a short summary, the “problem” is, that there is a standard for “answer-files” for deb packages called debconf. This answers can be made visible AFTER the setup, so you can automate future setups:

To convert this debconf selection into reusable code for future deployments, you could write something like this:

Sadly the msodbcsql17 deb package ignores this settings, which is the reason Markus Kuhn and Jan Katins posted updated GitHub code Gists which would solve this issue.

The solution

As this wasn’t implemented by Microsoft just yet, I dug into the original files and searched for the install behavior. In the Microsoft repository in the msodbcsql17 deb file archive is a file called “preinst”. It has a function which starts with the following IF function:

As you can see, nobody (seems to) care about debconf, but checks the value of a BASH variable. This led me to the conclusion, that an environment variable managed by saltstack could solve the issue:

Which results in the following unattended package install state for saltstack:

Result of state.apply:

Appendix: The Microsoft repository

As I use a saltstack state to manage the Microsoft repository in my example code, it might be interesting for others to see my state declaration for it:

Author: Marco

Marco is an IT-System administrator and IT-Consultant with 10+ years experience. He is specialized in the delivery of virtual Apps and Desktops with Citrix solutions. In 2017 he has been awarded Citrix Technology Advocate by Citrix for his community work (#CTA). His second core area is availability & performance monitoring with Zabbix, a leading open-source solution. His employer is the German IT-Company ANAXCO, which is developing a Transport Management Software (TMS) based on Microsoft Dynamics AX. More about Marco

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.