0

I am trying to query the sql server from ansible controller. Using the ansible-galaxy in built collections. The server is accessible and WINRM is working. But still I am getting the below error message. Can anyone suggest what is the issue ? TIA

https://docs.ansible.com/ansible/devel//collections/community/general/mssql_script_module.html

YML file.

  • hosts: win gather_facts: no collections:
    • community.general tasks:
    • name: Check DB connection community.general.mssql_script: login_user: "testadmin" login_password: "test@12345" login_host: "xxxxxxxx\SQLEXPRESS" login_port: "1433" db: master script: "SELECT 1"

Error message

fatal: [x.x.x.x]: 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:29\r\n+ excludes = set(('', '.', scriptdir))\r\n+ ~\r\nMissing expression after ','.\r\nAt line:15 char:30\r\n+ excludes = set(('', '.', scriptdir))\r\n+ ~~~~~~~~~\r\nUnexpected token 'scriptdir' in expression or statement.\r\nAt line:15 char:29\r\n+ excludes = set(('', '.', scriptdir))\r\n+ ~\r\nMissing closing ')' in expression.\r\nAt line:15 char:39\r\n+ excludes = set(('', '.', scriptdir))\r\n+ ~\r\nUnexpected token ')' in expression or statement.\r\nAt line:15 char:40\r\n+ excludes = set(('', '.', scriptdir))\r\n+ ~\r\nUnexpected token ')' in expression or 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\nNot all parse errors were reported. Correct the reported errors and try again."\r\nAt line:10 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 valid. It must result in a command \r\nname, a script block, or a CommandInfo object.\r\nAt line:11 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 }

ssethi
  • 13
  • 3
  • Aside... `login_host: "xxxxxxxx\SQLEXPRESS" login_port: "1433"` seems like an unlikely combination. Unless you've specifically reconfigured the Server Protocols in SQL Server Configuration Manager, the default `MSSQLSERVER` instance is usually listening on 1433 and SQL Express will be on a dynamic high-numbered port (i.e.: somewhere in the 49152-65535 range). – AlwaysLearning Jul 06 '22 at 11:43
  • `Missing argument in parameter list` sounds like a scripting error rather than a communications problem. Have you used Ansible Lint to check your file? – AlwaysLearning Jul 06 '22 at 11:45
  • Thanks @AlwaysLearning , For first issue I have changed the port value to 1433 in SQL Server. For Second issue , the scripting is done in visual studio with proper YAML format. – ssethi Jul 07 '22 at 13:42

0 Answers0