Reputation: 1431
I am trying to copy files from a remote host to my local server where I am running Ansible playbook. Though the task always executes successfully but the file is never copied to local server. Here is the code:
- file:
path: vm_info.config
mode: 0777
- fetch:
src: vm_info.config
dest: .
#flat: yes
fail_on_missing: yes
I tried copy module as well but none of them is getting me the result.
Upvotes: 3
Views: 8882
Reputation: 52443
From fetch - Fetches a file from remote nodes
dest - A directory to save the file into. For example, if the dest directory is /backup a src file named /etc/profile on host host.example.com, would be saved into /backup/host.example.com/etc/profile
So look in ./remote-host/vm_info.config
. For example, your remote host is 192.168.1.3, the fetched file will be: ./192.168.1.3/vm_info.config
If you had used -v option, it would have printed the location of the fetched file. I ran the playbook from /tmp directory.
TASK [fetch] ******************************************************************* changed: [192.168.1.99] => {"changed": true, "checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "dest": "/tmp/192.168.1.3/vm_info.config", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "remote_checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "remote_md5sum": null}
root@ip-192-168-1-99:~$ ls -l /tmp/192.168.1.3/vm_info.config
-rwxrwxr-x 1 root root 0 Dec 16 23:58 /tmp/192.168.1.3/vm_info.config
Upvotes: 6