Windows print out contents of a file to stdout to debug

Hi,

I’m trying to print out a file’s content on a Windows role and then use the debug module to output to the console, this uses similar notation to print out files contents on a unix platform for ansible.

  • name: windows | register log file

shell: “type c:\log.txt”

register: logFile

  • name: windows | print out log file

debug:

msg: “{{ logFile.stdout }}”

However, I’m getting this error on the first step:

TASK [templates : windows | register log file] ***************************************************************************************

[WARNING]: FATAL ERROR DURING FILE TRANSFER:

fatal: [inf]: FAILED! => {“msg”: "winrm send_input failed; \nstdout: Unable 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, 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:1\r\n+ ANSIBALLZ_WRAPPER = True # For test-module script to tell this is a A …

etc…

Can someone point me how to do this correctly on Windows? (using Ansible 2.6.2)

Thanks in advance! :slight_smile:

Hi,

I'm trying to print out a file's content on a Windows role and then use the
debug module to output to the console, this uses similar notation to print
out files contents on a unix platform for ansible.

- name: windows | register log file
shell: "type c:\\log.txt"
register: logFile

<snio />

Can someone point me how to do this correctly on Windows? (using Ansible
2.6.2)

It's in the documentation
https://docs.ansible.com/ansible/2.6/modules/shell_module.html#synopsis

The second bullet point reads "For Windows targets, use the win_shell module instead."

Oof yeah that’s it - thank you!