Ansible indeed commuicates wth Windows via WinRM as standard Windows protocol for remote management.
Latest version of Ansible and latest version of Windows also support communication via SSH.
If you need to execute some SQL script on MS SQL, you have 2 directions:
1. (simler for Windows guy). Use WinRM connection from Ansible to Windows Server where MS SQL is installed.
- use credssp
- use Kerberos delegation
There methods will help in case you are using Windows only authentiation on SQL side.
If you want to use sql login, you supply alternate credentials in sqlcmd or invoke-sqlcmd in case you are using sql logins.
This would be rather quick way to achieve what you need though win_shell and win_command are anti-patterns for Ansible's declarative approach.
2. (simpler for Python guy) Use delegation and run query from Ansible host. You will have to create some python code (ideally in form of Ansible module) what will connect to SQL from Ansible controller and execute the script. In this case you will connect from Ansible host to MS SQL via 1433/tcp.
Thank you,
- Igor