In ansible how do cp -rp

83 views
Skip to first unread message

ryad9...@gmail.com

unread,
Mar 21, 2019, 1:00:28 PM3/21/19
to Ansible Project
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,

eric.b....@nasa.gov

unread,
Mar 21, 2019, 1:37:45 PM3/21/19
to Ansible Project
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

ryad9...@gmail.com

unread,
Mar 22, 2019, 4:25:09 AM3/22/19
to Ansible Project
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,

Dick Visser

unread,
Mar 22, 2019, 4:55:31 AM3/22/19
to ansible...@googlegroups.com
If your goal is to have two equal directories, then the synchronize
module would make sense.
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8f32ef3e-e01a-4806-9db2-09d95513b4d0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

ryad9...@gmail.com

unread,
Mar 22, 2019, 5:31:09 AM3/22/19
to Ansible Project
Hi,

Ok thanks,

i will try synchronize module in ansible.

Thank you,

Regards,
Reply all
Reply to author
Forward
0 new messages