Copy folder with subdirectories

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

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.

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.

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

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.

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.

Oh great, it works! This is so cool