# Microsoft SQL Server Module mssql\_db Not Working to create a Database.

**URL:** <https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 5, 2020, 6:13pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159 "2020-11-05T18:13:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Praveen\_Kumar\_Singh](https://forum.ansible.com/u/Praveen_Kumar_Singh)\
**Post date:** [November 5, 2020, 6:13pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/1 "2020-11-05T18:13:36Z")

</div>

ISSUE TYPE

- Feature Idea  
SUMMARY

When I am using the SQL Server Module mssql\_db to create a new database on the microsoft SQL Server I am getting the below error. Microsoft SQL Server is on windows server. I am using the below playbook to create the database on SQL Server.

Ansible Playbook :

- hosts: SQLSERVER  
vars:  
ansible\_python\_interpreter: /usr/bin/Python 2.7.5  
tasks:
  - mssql\_db:  
debug: var=ansible\_host  
login\_host: \*\*\*\*\*\*\*  
login\_user: Ansible  
login\_password: \*\*\*\*\*\*\*  
login\_port: 1433  
name: TestDB  
state: present

**ERROR** : fatal: [SQLSERVER]: FAILED! =\> {“changed”: false, “module\_stderr”: "Exception calling “Create” with “1” argument(s): “At line:4 char:21\r\n+ def \_ansiballz\_main():\r\n+ ~\r\nAn expression was expected after ‘(’.\r\nAt line:13 char:27\r\n+ except (AttributeError, OSError):\r\n+ ~\r\nMissing argument in parameter list.\r\nAt line:15 char:7\r\n+ if scriptdir is not None:\r\n+ ~\r\nMissing ‘(’ after ‘if’ in if statement.\r\nAt line:22 char:7\r\n+ if sys.version\_info \< (3,):\r\n+ ~\r\nMissing ‘(’ after ‘if’ in if statement.\r\nAt line:22 char:30\r\n+ if sys.version\_info \< (3,):\r\n+ ~\r\nMissing expression after ‘,’.\r\nAt line:22 char:25\r\n+ if sys.version\_info \< (3,):\r\n+ ~\r\nThe ‘\<’ operator is reserved for future use.\r\nAt line:27 char:34\r\n+ def invoke\_module(modlib\_path, temp\_path, json\_params):\r\n+ ~\r\nMissing argument in parameter list.\r\nAt line:28 char:40\r\n+ z = zipfile.ZipFile(modlib\_path, mode=‘a’)\r\n+ ~\r\nMissing argument in parameter list.\r\nAt line:31 char:33\r\n+ zinfo = zipfile.ZipInfo()\r\n+ ~\r\nAn expression was expected after ‘(’.\r\nAt line:34 char:25\r\n+ z.writestr(zinfo, sitecustomize)\r\n+ ~\r\nMissing argument in parameter list.\r\nNot all parse errors were reported. Correct the reported errors and try again.\r\n”\r\nAt line:6 char:1\r\n+ $exec\_wrapper = [ScriptBlock]::Create($split\_parts[0])\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (🙂 , MethodInvocationException\r\n + FullyQualifiedErrorId : ParseException\r\n \r\nThe expression after ‘&’ in a pipeline element produced an object that was not \r\nvalid. It must result in a command name, a script block, or a CommandInfo \r\nobject.\r\nAt line:7 char:2\r\n+ &$exec\_wrapper\r\n+~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidOperation: (🙂 , RuntimeException\r\n + FullyQualifiedErrorId : BadExpression\r\n ", “module\_stdout”: “”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}

ENVIRONMENT- Ansible version: ansible 2.9.13

- Operating System: Linux

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Praveen\_Kumar\_Singh](https://forum.ansible.com/u/Praveen_Kumar_Singh)\
**Post date:** [January 12, 2021, 5:59pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/2 "2021-01-12T17:59:25Z")

</div>

Hello Team,

Can someone please help me with this?

Thanks and Regards,  
Praveen Singh

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 12, 2021, 6:08pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/3 "2021-01-12T18:08:33Z")

</div>

> ISSUE TYPE
> 
> Feature Idea
> 
> SUMMARY
> 
> When I am using the SQL Server Module mssql\_db to create a new database on the microsoft SQL Server I am getting the below error. Microsoft SQL Server is on windows server. I am using the below playbook to create the database on SQL Server.
> 
> Ansible Playbook :
> 
> hosts: SQLSERVER  
> vars:  
> ansible\_python\_interpreter: /usr/bin/Python 2.7.5

Does this actually work without escaping the spaces?

> tasks:
> 
> mssql\_db:  
> debug: var=ansible\_host

'debug' isn't a parameter for the mssql\_db module. Remove that and try again.  
Also, try to post properly indented/copied code. Indentation in  
importantly, and the way you pasted it (using HTML disc?) makes it  
impossible to tell what went on.

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Praveen\_Kumar\_Singh](https://forum.ansible.com/u/Praveen_Kumar_Singh)\
**Post date:** [January 13, 2021, 7:32pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/4 "2021-01-13T19:32:52Z")

</div>

I removed the debug parameter and still get the error. I ran the below simple playbook which should create a database in sql server but I am still getting the error.

> **(attachments)**
>
> ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/a/a1d9e649a5980b0b94ef5320513714ec1b66f342.png)

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Praveen\_Kumar\_Singh](https://forum.ansible.com/u/Praveen_Kumar_Singh)\
**Post date:** [January 14, 2021, 1:02pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/5 "2021-01-14T13:02:25Z")

</div>

Can someone please help me on this.

Thanks and regards,  
Praveen Singh

> **(attachments)**
>
> ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/a/a1d9e649a5980b0b94ef5320513714ec1b66f342.png)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 14, 2021, 1:31pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/6 "2021-01-14T13:31:25Z")

</div>

what is the output of

/usr/bin/Python 2.7.5 --version

and:

ansible --version

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@Praveen\_Kumar\_Singh](https://forum.ansible.com/u/Praveen_Kumar_Singh)\
**Post date:** [January 14, 2021, 3:06pm UTC](https://forum.ansible.com/t/microsoft-sql-server-module-mssql-db-not-working-to-create-a-database/34159/7 "2021-01-14T15:06:13Z")

</div>

Hello Dick,

Below is the information.

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/a/aa7dd7580d724bf9d01aa591d37ac632c9215789.png)
