Microsoft SQL Server Module mssql_db Not Working to create a Database.

75 views
Skip to first unread message

Praveen Kumar Singh

unread,
Nov 5, 2020, 1:13:36 PM11/5/20
to Ansible Project
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

Praveen Kumar Singh

unread,
Jan 12, 2021, 12:59:25 PM1/12/21
to Ansible Project
Hello Team,

Can someone please help me with this?

Thanks and Regards,
Praveen Singh

Dick Visser

unread,
Jan 12, 2021, 1:09:01 PM1/12/21
to ansible...@googlegroups.com
On Thu, 5 Nov 2020 at 19:13, 'Praveen Kumar Singh' via Ansible Project
<ansible...@googlegroups.com> wrote:
>
> 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.

> 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
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/49d93260-95a5-443d-bacc-102243e1afe0n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Praveen Kumar Singh

unread,
Jan 13, 2021, 2:33:20 PM1/13/21
to ansible...@googlegroups.com
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. 

---
 - hosts: SQLSERVER2

   vars:
    ansible_python_interpreter: /usr/bin/Python 2.7.5
   tasks:
     - mssql_db:
        name: TestDB
        state: present

image.png

Thanks and Regards,
Praveen Singh

Praveen Kumar Singh

unread,
Jan 14, 2021, 8:02:51 AM1/14/21
to ansible...@googlegroups.com
Can someone please help me on this.

Thanks and regards,
Praveen Singh

Dick Visser

unread,
Jan 14, 2021, 8:31:48 AM1/14/21
to ansible...@googlegroups.com
what is the output of

/usr/bin/Python 2.7.5 --version

and:

ansible --version

On Thu, 14 Jan 2021 at 14:02, 'Praveen Kumar Singh' via Ansible
Project <ansible...@googlegroups.com> wrote:
>
> Can someone please help me on this.
>
> Thanks and regards,
> Praveen Singh
>
> On Wed, Jan 13, 2021 at 11:32 AM Praveen Kumar Singh <prav...@tibco.com> wrote:
>>
>> 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.
>>
>> ---
>> - hosts: SQLSERVER2
>> vars:
>> ansible_python_interpreter: /usr/bin/Python 2.7.5
>> tasks:
>> - mssql_db:
>> name: TestDB
>> state: present
>>
>>
>>
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJK1W%3Dzk0TGeuQRb_YRS2xDhAgG_%3DNE9uB3sNUOudRWNpk55Cw%40mail.gmail.com.

Praveen Kumar Singh

unread,
Jan 14, 2021, 10:06:36 AM1/14/21
to ansible...@googlegroups.com
Hello Dick,

Below is the information.

image.png

Reply all
Reply to author
Forward
0 new messages