I need to know if I can add new records to MS SQL Server DB as part of Ansible playbook.
We are trying to keep records in MSSQL Server of each deployment we have done, and it would be very convenient if it could be done directly from the playbook, since this will guarantee that for every host, when the deployment pass- it is updated directly
There are two options:
Using ansible command module with sqlcmd
tool: https://learn.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017
Implement you custom module in python with use of pyodbc
: https://learn.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server?view=sql-server-2017
There are several python SQL drivers available. However, Microsoft places its testing efforts and its confidence in pyodbc driver
I am currently using first option with prepared statement in jinja on my ubuntu machine and it works fine.