Jordan, Thanks a million. I was able to get the output I'm looking for. Now that have the list of files in my C:\Temp, how do I fetch those files to my ansible controller host? Here's an example I have so far but failing at one section.
*- hosts: all gather_facts: yes tasks: - win_shell: dir /b C:\Temp\*.tar args: executable: cmd register: results - debug: var: results.stdout_lines - name: get the files fetch: src: "C:/Temp/{{ item }}" dest: /home/vagrant/win-script-result/ flat: yes with_items: "{{ results.stdout_lines }}"* TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************************************************************************************** ok: [SV1] ok: [SV2] TASK [win_shell] ******************************************************************************************************************************************************************************************************************************************************************************************************** changed: [SV1] changed: [SV2] TASK [debug] ************************************************************************************************************************************************************************************************************************************************************************************************************ ok: [SV1] => { "results.stdout_lines": [ "1709051418.tar", "1709051525.tar", "1709052115.tar" ] } ok: [SV2] => { "results.stdout_lines": [ "1709051421.tar", "1709051527.tar", "1709052107.tar" ] } TASK [get the files] **************************************************************************************************************************************************************************************************************************************************************************************************** fatal: [SV1]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'item' is undefined\n\nThe error appears to have been in '/home/vagrant/ansible/find-copy-test.yml': line 12, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: get the files\n ^ here\n"} fatal: [SV2]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'item' is undefined\n\nThe error appears to have been in '/home/vagrant/ansible/find-copy-test.yml': line 12, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: get the files\n ^ here\n"} to retry, use: --limit @/home/vagrant/ansible/find-copy-test.retry On Wednesday, October 11, 2017 at 4:32:06 PM UTC-4, marcalfa1 wrote: > > > Trying to "dir /b c:\Temp" using a playbook or via adhoc and getting the > error message below. It seems to have a problem with "/b" in "Dir /b > C:\Temp" > > > > > > > > *- hosts: all gather_facts: yes tasks: - win_shell: dir /b C:\Temp* > > FAILED! => {"changed": true, "cmd": "dir /b C:\\Temp", "delta": > "0:00:00.839042", "end": "2017-10-11 08:22:02.820065", "failed": true, > "rc": 1, "start": "2017-10-11 08:22:01.981022", "stderr": "dir : Cannot > find path 'C:\\b' because it does not exist.\r\nAt line:1 char:65\r\n+ > [Console]::InputEncoding = New-Object Text.UTF8Encoding $false; dir /b > \r\nC:\\Temp\r\n+ > > \r\n~~~~~~~~~~~~~~\r\n + CategoryInfo : ObjectNotFound: > (C:\\b:String) [Get-ChildItem], I \r\n temNotFoundException\r\n + > FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh > \r\n ildItemCommand", "stderr_lines": ["dir : Cannot find path 'C:\\b' > because it does not exist.", "At line:1 char:65", "+ > [Console]::InputEncoding = New-Object Text.UTF8Encoding $false; dir /b ", > "C:\\Temp", > "+ ", > "~~~~~~~~~~~~~~", " + CategoryInfo : ObjectNotFound: > (C:\\b:String) [Get-ChildItem], I ", " temNotFoundException", " + > FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh ", > " ildItemCommand"], "stdout": "", "stdout_lines": []} > > > *ansible -i poc-win all -m raw -a "dir /b C:\Temp"* > | FAILED | rc=1 >> > *dir : Cannot find path 'C:\b' because it does not exist*. > At line:1 char:1 > + dir /b C:\Temp > + ~~~~~~~~~~~~~~ > + CategoryInfo : ObjectNotFound: (C:\b:String) > [Get-ChildItem], I > temNotFoundException > + FullyQualifiedErrorId : > PathNotFound,Microsoft.PowerShell.Commands.GetCh > ildItemCommand > > > *ansible -i poc-win all -m win_shell -a "dir /b C:\Temp"* > | FAILED | rc=1 >> > dir : Cannot find path 'C:\b' because it does not exist. > At line:1 char:65 > + [Console]::InputEncoding = New-Object Text.UTF8Encoding $false; dir /b > C:\Temp > + > ~~~~~~~~~~~~~~ > + CategoryInfo : ObjectNotFound: (C:\b:String) > [Get-ChildItem], I > temNotFoundException > + FullyQualifiedErrorId : > PathNotFound,Microsoft.PowerShell.Commands.GetCh > ildItemCommand > > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ca1a2e4d-db6d-4be3-bf1c-f526195479d7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.