[Ansible] Auto Accept License When Install msodbcsql17 rpm

Tony
2 min readMar 16, 2021

--

If you want to use Python pypyodbc library and connect to a MSSQL instance on a CentOS Linux server, you will need to have at least the following three rpm packages installed:

  • msodbcsql17
  • unixODBC
  • unixODBC-devel

All above rpm packages can be download from https://packages.microsoft.com/rhel/7/prod/

However, when you try to use Ansible to automate the installation process, you may run into the following issue which the msodbcsql17 rpm install requires a user interaction to accept the license:

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)

This is pretty annoying that each time you need to manually accept the license. This blog shows you how to fix it and make your Ansible playbook fully automated.

Environment

  • OS: CentOS
  • Ansible: 2.3.3.0+

Issue

Ansible playbook runs need human interaction:

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
changed: [localhost] => {
...

Fix

You will need to update the “install step” in your Ansible playbook, add environment configuration:

- name: Install unixODBC
yum:
state: present
name:
- /tmp/msodbcsql.rpm
# Disable all repos since we install local
disablerepo: "*"
environment:
ACCEPT_EULA: 'y'

Then you should be able to run your Ansible playbook without any human interaction.

--

--

Tony
Tony

No responses yet