unable to execute a perl script on windows server

Hi,

I am trying to run a run a perl script in the windows server using ansible playbook located in linux and getting the below error.Can some one help me.

“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\nAt line:6 char:1\r\n+ $exec_wrapper = [ScriptBlock]::Create($split_parts[0])\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:slight_smile: , 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 name,\r\n a script block, or a CommandInfo object.\r\nAt line:7 char:2\r\n+ &$exec_wrapper\r\n+ ~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException\r\n + FullyQualifiedErrorId : BadExpression\r\n ",
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}

Playbook:

  • hosts: SRM

vars:
ansible_become_user: ‘{{ ansible_user }}’
release_version: “Latest”

tasks:

  • name: “upgrade DW for {{dw_instance_1}}”
    become: yes
    become_user: Administrator
    shell: ssh {{ ansible_user }}@{{ ansible_host }} “D:” && cd D:\AMG\SRM\{{ kit_name.stdout }}\ && perl srm_upgrade.pl –dw-instance={{dw_instance_1}}

shell: ssh {{ ansible_user }}@{{ ansible_host }} “D:” && cd D:\AMG\SRM\{{ kit_name.stdout }}\ && perl srm_upgrade.pl –dw-instance={{dw_instance_1}}

Why do you do the ssh? ansible does that by default. Does your Windows machine support ssh? perl?

Walter

Hi,

Modified it without ssh and still got the same error. Ran the perl script manually and connection from ansible to the windows machine works as well.

Modified to below:
shell: ‘“D:” && cd D:\AMG\SRM\{{ kit_name.stdout }}\ && perl srm_upgrade.pl –dw-instance={{dw_instance_1}}’

ASK [upgrade DW for 41] **********************************************************************************************************************************************************************************
task path: /opt/ansible/tsn_playbooks/playground/upgrade-srm.yaml:24
Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
Pipelining is enabled.
<159.79.80.120> ESTABLISH SSH CONNECTION FOR USER: svc_sentf_ssh
<159.79.80.120> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ‘User=“svc_sentf_ssh”’ -o ConnectTimeout=10 -o ControlPath=/opt/ansible/.ansible/cp/a65f93f539 159.79.80.120 ‘chcp.com 65001 >nul 2>&1 && PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAb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cAVQBBAFkAdwBCAGYAQQBIAGMAQQBjAGcAQgBoAEEASABBAEEAYwBBAEIAbABBAEgASQBBAEkAQQBBADkAQQBDAEEAQQBXAHcAQgBUAEEARwBNAEEAYwBnAEIAcABBAEgAQQBBAGQAQQBCAEMAQQBHAHcAQQBiAHcAQgBqAEEARwBzAEEAWABRAEEANgBBAEQAbwBBAFEAdwBCAHkAQQBHAFUAQQBZAFEAQgAwAEEARwBVAEEASwBBAEEAawBBAEgATQBBAGMAQQBCAHMAQQBHAGsAQQBkAEEAQgBmAEEASABBAEEAWQBRAEIAeQBBAEgAUQBBAGMAdwBCAGIAQQBEAEEAQQBYAFEAQQBwAEEAQQBvAEEASgBnAEEAawBBAEcAVQBBAGUAQQBCAGwAQQBHAE0AQQBYAHcAQgAzAEEASABJAEEAWQBRAEIAdwBBAEgAQQBBAFoAUQBCAHkAQQBBAD0APQA=’
<159.79.80.120> (1, ‘’, ‘#< CLIXML\r\nSystem.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 Exception calling “Create” with “1” argument(s): "At line:4 char:21_x000D__x000A_+ def ansiballz_main():x000D__x000A+ ~x000D__x000AAn expression was expected after '('.x000D__x000AAt line:13 char:27_x000D__x000A+ except (AttributeError, OSError):x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000AAt line:15 char:7_x000D__x000A_+ if scriptdir is not None:x000D__x000A+ ~x000D__x000AMissing '(' after 'if' in if statement.x000D__x000AAt line:22 char:7_x000D__x000A_+ if sys.version_info < (3,):x000D__x000A+ ~x000D__x000AMissing '(' after 'if' in if statement.x000D__x000AAt line:22 char:30_x000D__x000A_+ if sys.version_info < (3,):x000D__x000A+ ~x000D__x000AMissing expression after ','.x000D__x000AAt line:22 char:25_x000D__x000A_+ if sys.version_info < (3,):x000D__x000A+ ~x000D__x000AThe '<' operator is reserved for future use.x000D__x000AAt line:27 char:34_x000D__x000A_+ def invoke_module(modlib_path, temp_path, json_params):x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000AAt line:28 char:40_x000D__x000A_+ z = zipfile.ZipFile(modlib_path, mode='a')x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000AAt line:31 char:33_x000D__x000A_+ zinfo = zipfile.ZipInfo()x000D__x000A+ ~x000D__x000AAn expression was expected after '('.x000D__x000AAt line:34 char:25_x000D__x000A_+ z.writestr(zinfo, sitecustomize)x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000ANot all parse errors were reported. Correct the reported errors and try again."x000D__x000AAt line:6 char:1_x000D__x000A_+ $exec_wrapper = [ScriptBlock]::Create($split_parts[0])x000D__x000A+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~x000D__x000A + CategoryInfo : NotSpecified: (:slight_smile: , MethodInvocationException_x000D__x000A_ + FullyQualifiedErrorId : ParseException_x000D__x000A_ x000D__x000AThe expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name,x000D__x000A a script block, or a CommandInfo object.x000D__x000AAt line:7 char:2_x000D__x000A_+ &$exec_wrapper_x000D__x000A_+ ~~~~~~~~~~~~~x000D__x000A + CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException_x000D__x000A_ + FullyQualifiedErrorId : BadExpression_x000D__x000A_ x000D__x000A’)
<159.79.80.120> Failed to connect to the host via ssh: #< CLIXML
System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 Exception calling “Create” with “1” argument(s): "At line:4 char:21_x000D__x000A_+ def ansiballz_main():x000D__x000A+ ~x000D__x000AAn expression was expected after ‘(’.x000D__x000AAt line:13 char:27_x000D__x000A+ except (AttributeError, OSError):x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000AAt line:15 char:7_x000D__x000A_+ if scriptdir is not None:x000D__x000A+ ~x000D__x000AMissing ‘(’ after ‘if’ in if statement.x000D__x000AAt line:22 char:7_x000D__x000A_+ if sys.version_info < (3,):x000D__x000A+ ~x000D__x000AMissing ‘(’ after ‘if’ in if statement.x000D__x000AAt line:22 char:30_x000D__x000A_+ if sys.version_info < (3,):x000D__x000A+ ~x000D__x000AMissing expression after ‘,’.x000D__x000AAt line:22 char:25_x000D__x000A_+ if sys.version_info < (3,):x000D__x000A+ ~x000D__x000AThe ‘<’ operator is reserved for future use.x000D__x000AAt line:27 char:34_x000D__x000A_+ def invoke_module(modlib_path, temp_path, json_params):x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000AAt line:28 char:40_x000D__x000A_+ z = zipfile.ZipFile(modlib_path, mode=‘a’)x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000AAt line:31 char:33_x000D__x000A_+ zinfo = zipfile.ZipInfo()x000D__x000A+ ~x000D__x000AAn expression was expected after ‘(’.x000D__x000AAt line:34 char:25_x000D__x000A_+ z.writestr(zinfo, sitecustomize)x000D__x000A+ ~x000D__x000AMissing argument in parameter list.x000D__x000ANot all parse errors were reported. Correct the reported errors and try again."x000D__x000AAt line:6 char:1_x000D__x000A_+ $exec_wrapper = [ScriptBlock]::Create($split_parts[0])x000D__x000A+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~x000D__x000A + CategoryInfo : NotSpecified: (:slight_smile: , MethodInvocationException_x000D__x000A_ + FullyQualifiedErrorId : ParseException_x000D__x000A_ x000D__x000AThe expression after ‘&’ in a pipeline element produced an object that was not valid. It must result in a command name,x000D__x000A a script block, or a CommandInfo object.x000D__x000AAt line:7 char:2_x000D__x000A_+ &$exec_wrapper_x000D__x000A_+ ~~~~~~~~~~~~~x000D__x000A + CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException_x000D__x000A_ + FullyQualifiedErrorId : BadExpression_x000D__x000A_ x000D__x000A
fatal: [SE20GITVRST10]: 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\nAt line:6 char:1\r\n+ $exec_wrapper = [ScriptBlock]::Create($split_parts[0])\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:slight_smile: , 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 name,\r\n a script block, or a CommandInfo object.\r\nAt line:7 char:2\r\n+ &$exec_wrapper\r\n+ ~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException\r\n + FullyQualifiedErrorId : BadExpression\r\n ",
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,

I will have to defer to others on this one. I don’t run ssh or perl on Windows servers. Our ansible connections to Windows servers are made over WinRM.

Walter

I was able to create a directory as well as copy over some files to the windows machine using ansible using shell module. but I couldn’t run this script. So bit confused over here.