# Copy folder with subdirectories

**URL:** <https://forum.ansible.com/t/copy-folder-with-subdirectories/13121>\
**Category:** Ansible Project\
**Created:** [July 15, 2013, 8:08am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121 "2013-07-15T08:08:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kialeo](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@kialeo](https://forum.ansible.com/u/kialeo)\
**Post date:** [July 15, 2013, 8:08am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/1 "2013-07-15T08:08:19Z")

</div>

Is it possible to copy folder including all subdirectories to server. Folder with files can be done with with\_fileglob. What about subdirectories?

---

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [July 15, 2013, 9:12am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/2 "2013-07-15T09:12:37Z")

</div>

[https://groups.google.com/forum/#!topic/ansible-project/-GdHVECpSeU](https://groups.google.com/forum/#!topic/ansible-project/-GdHVECpSeU)

I did try:

local\_action: rsync home/celine/Desktop/folder $inventory\_hostname/home/celine2/Desktop/newFolder

However, there is error. “module rsync not found in /usr/share/asible/inventory…”

Not sure if you have the same error as me.

Can try tar and “untar” also. But not a nice way to do it though.

---

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [July 15, 2013, 9:52am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/3 "2013-07-15T09:52:36Z")

</div>

Realised i am lacking the “command”

local\_action: command rsync home/celine/Desktop/folder $inventory\_hostname:/home/celine2/Desktop/newFolder

But this time round it keeps prompting for password… which i do not have any. Hence still fail.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 15, 2013, 2:11pm UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/4 "2013-07-15T14:11:40Z")

</div>

It’s recommended you set up authorized keys in this case.

---

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [July 16, 2013, 1:37am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/5 "2013-07-16T01:37:55Z")

</div>

I have setup ssh key pair and am able to ssh in without typing password or passphrase.

but it still prompts me for password which i dont know what the password is. I tried typing admin password but also fail.

Error msg: stderr: Permission denied (publickey,keyboard-interactive).  
rsync: connection unexpectedly closed (0bytes reeived so far) [sender]  
rsync error: unexplained error (code 255) at io.c(632) [sender=3.0.4]

without ansible, i am able to do rsync without having to type passphrase or password.

---

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [July 16, 2013, 6:33am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/6 "2013-07-16T06:33:58Z")

</div>

It works when i do this:

local\_action: rsync home/celine/Desktop/folder server@$inventory\_hostname:/home/celine2/Desktop/newFolder

my $inventory\_hostname has only ip. needs username to work.

---

<div class="post-metadata">

**Author:** ![kialeo](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@kialeo](https://forum.ansible.com/u/kialeo)\
**Post date:** [July 16, 2013, 6:56am UTC](https://forum.ansible.com/t/copy-folder-with-subdirectories/13121/7 "2013-07-16T06:56:24Z")

</div>

Oh great, it works! This is so cool
