Missing something with host directory/file paths

735 views
Skip to first unread message

Jon Langemak

unread,
Aug 31, 2016, 5:31:49 PM8/31/16
to Ansible Project
It's been awhile since I played with Ansible and right now Im tearing my hair out on this copy problem.  Im trying to copy a directory on a Linux host to a new location.  In ad-hoc ansible, it looks like this...

ansible -m copy -a "src=/usr/share/folder1 dest=/config/folder2" servers

When I run this command, Ansible tells me it can't find the directory...

10.10.10.107 | FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "Unable to find '/usr/share/folder1' in expected paths."
}

Yet, when I go on the host, I can clearly see that the source directory exists.  Im thinking this is something terribly obvious since I've now tried this on multiple hosts and get the same error each time.  I know Ansible is working because I can run adhoc shell commands and touch files, see the pwd, etc.  

Any ideas at all?  What am I missing?

Thanks!

Brian Coca

unread,
Aug 31, 2016, 6:19:57 PM8/31/16
to ansible...@googlegroups.com
by default ansible looks in the local 'controller' for the `src=` parameter, you need to use `remote_src=yes` for it to look for it on the target machine.

Also note that `remote_src=yes` does not support recursive copying.


----------
Brian Coca

Jon Langemak

unread,
Aug 31, 2016, 8:09:22 PM8/31/16
to Ansible Project
Thank you!  Is there a better means to recursively copy then?  Or do I need to copy each file separately?

Jon Langemak

unread,
Sep 1, 2016, 11:55:01 AM9/1/16
to Ansible Project
I'll answer this for myself.  Seems like just using the command module and doing the copy that way is the best approach.

Thanks for putting me on the right track!
Reply all
Reply to author
Forward
0 new messages