In ansible how do cp -rp

Hi all,

I want do this command line in ansible :

cp -rp /home/user/file1 /home/user/directory2/file2

I have find this module copy :

- name: example copying file with owner and permissions
  copy:
    src: /srv/myfiles/foo.conf
    dest: /etc/foo.conf
    owner: foo
    group: foo
    mode: 0644
this task works But this task not sauvegarde all caracteristic of file1 (**date create**, etc ...) as linux command **"cp -rp /****home/user/file1 /home/user/directory2/file2"**
Someone have an idea please ? 
Thanks community ansible !! ;)
Regards,

Ansible has a “shell” and a “command” module, both of which allow you to pass arbitrary Unix commands to the remote host.

Also, the -r flag has no use on a single file.

–EbH

Hi Eric,

Yes but the subject is -p since I’m mainly interested in keeping all the characteristics of the file …
In addition, I know that there is shell and command in ansible but I want a “syntax” ansible. The objective with ansible it is to use its modules (example: service, get_url, etc …) otherwise one does that shell and command and the problem and to regulate, that will return to make a script bash: /

Regards,

If your goal is to have two equal directories, then the synchronize
module would make sense.

Hi,

Ok thanks,

i will try synchronize module in ansible.

Thank you,

Regards,