winrm send_input failed. help needed.

24 views
Skip to first unread message

Chris Jackson

unread,
Jul 3, 2019, 5:24:10 AM7/3/19
to Ansible Development

Hello,

My playbook is failing with a long error:

winrm send_input failed; \nstdout: Unable to initialize device PRN\r\nUnable to initialize device PRN\r\nUnable to initialize device PRN\r\nUnable to initialize device PRN\r\nUnable to initialize device PRN\r\n\nstderr _ANSIBALLZ_WRAPPER : The term '_ANSIBALLZ_WRAPPER' is not recognized as the name of a cmdlet, function, script file, \r\nor operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and \r\ntry again.\r\nAt line:1 char:1\r\n+ _ANSIBALLZ_WRAPPER = True # For test-module script to tell this is a  ...\r\n+ ~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (_ANSIBALLZ_WRAPPER:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\nAt line:1 char:21\r\n+ def _ansiballz_main():\r\n+                     ~\r\nAn expression was expected after '('.\r\n    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException\r\n    + FullyQualifiedErrorId : ExpectedExpression\r\n \r\nimport : The term 'import' is not recognized as the name of a cmdlet, function, script file, or operable program. \r\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:5\r\n+     import os\r\n+     ~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (import:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\nimport : The term 'import' is not recognized as the name of a cmdlet, function, script file, or operable program. \r\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:5\r\n+     import os.path\r\n+     ~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (import:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\nimport : The term 'import' is not recognized as the name of a cmdlet, function, script file, or operable program. \r\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:5\r\n+     import sys\r\n+     ~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (import:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\nimport : The term 'import' is not recognized as the name of a cmdlet, function, script file, or operable program. \r\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:5\r\n+     import __main__\r\n+     ~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (import:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\nscriptdir : The term 'scriptdir' is not recognized as the name of a cmdlet, function, script file, or operable \r\nprogram. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:5\r\n+     scriptdir = None\r\n+     ~~~~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (scriptdir:String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\ntry: : The term 'try:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check \r\nthe spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:5\r\n+     try:\r\n+     ~~~~\r\n    + CategoryInfo          : ObjectNotFound: (try::String) [], CommandNotFoundException\r\n    + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\n__main__.__file__ : The term '__main__.__file__' is not recognized as the name of a cmdlet, function, script file, or \r\noperable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try \r\nagain.\r\nAt line:1 char:54\r\n+ ...      scriptdir = os.path.dirname(os.path.realpath(__main__.__file__))\r\n+                                                       ~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : ObjectNotFound: (__main__.__file__:String)

I understand from a previous post that this may have something to do with Ansible expecting a python script but getting a powershell script instead. I am executing a role which is as follows:-

- name: Ensure that the temporary unpacking area is there
  file:
    path: "{{ package_install_home }}"
    state: directory
    recurse: yes

- name: Get the package from the artifactory and install it
  include_tasks: Windows_Get_And_Install_MSI.yml
  with_items: "{{ lookup('dict', artifacts) }}"

- name: Copy the powershell script to the remote system
  win_copy:
    src: files/ModifyPath.ps1
    dest: "{{ package_install_home }}"

- name: Modify the system path so that perl.exe is visible
  win_command: "powershell.exe {{ package_install_home }}\\ModifyPath.ps1"

Can anyone help?

Kind Regards

Chris.

Jordan Borean

unread,
Jul 3, 2019, 7:02:41 AM7/3/19
to Ansible Development
You can’t use Python modules on a Windows host, use win_file and not file.

Thanks

Jordan

Chris Jackson

unread,
Jul 3, 2019, 8:58:48 AM7/3/19
to Ansible Development
Thanks Jordan,

The playbook has now moved on and now i am getting the following error:-

'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'name'

this is being generated from an include_tasks on the following YAML:

 name: Get the package from the artifactory
  win_uri:
    url: "{{ artifactory_path }}/{{ this_artifact.name }}/{{ this_artifact.version }}/{{ this_artifact.package }}"
    method: GET
    headers:
      X-JFrog-Art-Api: "{{ artifactory_api_key }}"
    dest: "{{ package_install_home }}"

- name: Install the .msi package
  win_package:
    path: "{{ package_install_home }}\\{{ this_artifact.package }}"
    arguments: "/i /qb TARGETDIR=d:\\perl  INSTALLDIR=d:\\strawberry\\perl"
    state: present

Any ideas?

Chris

Tony Chia

unread,
Jul 3, 2019, 2:24:11 PM7/3/19
to Ansible Development
 Can you use the debug module and print out the variable this_artifact.name ?

It appears you have registered this_artifact in previous tasks but I suspect it doesn't have name attribute after this_artifact.  You might have to use this_artifact.stdout.name or something like that.

Tony

Chris Jackson

unread,
Jul 4, 2019, 5:18:43 AM7/4/19
to Ansible Development
Thanks Tony,

Yes, you were right - I needed {{ this_artifact.value.name }}

Chris.

Tony Chia

unread,
Jul 4, 2019, 2:17:08 PM7/4/19
to Ansible Development
Btw you can use ARA to display the output of each registered variables without using the debug module

Another side benefits is that it keeps your execution logs so you can refers to it later

https://ara.readthedocs.io/en/latest/

Reply all
Reply to author
Forward
0 new messages