winrm send_input failed. help needed.

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: (:slight_smile: [], 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.

You can’t use Python modules on a Windows host, use win_file and not file.

Thanks

Jordan

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

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

Thanks Tony,

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

Chris.

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/