Reputation: 61
I'm trying to get a file from a windows DFS share to the localhost (linux) to parse it later.
The path to the file is something like : \\windows_host\folder\file
And I'm trying to use the fetch module with something similar to this:
- name: Test
hosts: all
connection: local
gather_facts: no
tasks:
- name: Fetching a file from a Windows DFS Share
fetch:
src: \\windows_host\folder\file
dest: local_folder/file
flat: yes
But when I run it, it does not get the file and if I use the verbose option it says:
"msg": "the remote file does not exist, not transferring, ignored"
Though the file exists at the specific location.. so I think the problem is with the path encoding (I might be wrong) and I have tried a few different formats but so far no luck.
Does anyone know how to do that or what I'm doing wrong?
Alternative ways to get the file are also appreciated considering anyway that I'm not allowed to mount the share or to have any service (ftp/http/etc..) returning the file
Thanks in advance
ValerioG
Upvotes: 2
Views: 5222
Reputation: 61
I actually managed to make it work using the command module and smbclient command in linux. In case someone needs something similar, the playbook below works for me.
---
- name: Test
hosts: all
connection: local
gather_facts: no
vars_files:
- vault_with_AD_credentials.yaml
tasks:
- name: Getting the Exchange Data file from Windows Share
run_once: yes
command: smbclient '\\windows_host\share' -c 'lcd local_folder; cd remote_folder; get filename' -U {{ ad_username }}%{{ ad_password }}
Upvotes: 3