# Ansible create module connect MSSQL

**URL:** <https://forum.ansible.com/t/ansible-create-module-connect-mssql/31887>\
**Category:** Ansible Project\
**Created:** [December 30, 2019, 2:42pm UTC](https://forum.ansible.com/t/ansible-create-module-connect-mssql/31887 "2019-12-30T14:42:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [December 30, 2019, 2:42pm UTC](https://forum.ansible.com/t/ansible-create-module-connect-mssql/31887/1 "2019-12-30T14:42:45Z")

</div>

Hello,

I create module in file /library/module.py with this content :

#!/usr/bin/python

# -_- coding: utf-8 -_-

from ansible.module\_utils.basic import AnsibleModule  
from ansible.module\_utils.parsing.convert\_bool import BOOLEANS

DOCUMENTATION = ‘’’

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [December 31, 2019, 9:04am UTC](https://forum.ansible.com/t/ansible-create-module-connect-mssql/31887/2 "2019-12-31T09:04:39Z")

</div>

Worth running with -vvvvv to see if there is any more information to help you debug the problem.

Try this syntax as my guess is ansible is looking for a module called ‘module’ instead of your custome ‘mssql\_query’ module

`

- name: “Execut my module on MSSQL”  
mssql\_query:  
login\_host: my\_database\_name  
port: 1433  
login\_user: sa\_ofs  
login\_password: my\_password  
query: SELECT \* FROM dbo.my\_table  
db: my\_database  
autocommit: true  
tds\_version: 7.1  
as\_dict: false  
delegate\_to: my\_database\_name

`

Hope this helps,

Jon
