I don’t recall claiming that I was sane, only that the shell module would work. 
Plus, it is less work, being only five letters instead of seven.

--
Gerard Weatherby | Application Architect
NMRbox | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
uchc.edu<http://uchc.edu>
On Jan 18, 2021, 12:21 PM -0500, Stefan Hornburg (Racke) <[email protected]>, 
wrote:
On 1/18/21 6:18 PM, Gerard Weatherby wrote:
Just use shell and copy:

- hosts: all

  become: true

  tasks:

  - name: backup name

    set_fact:

      tdate: "bkp.{{ '%d%b%Y_%H%M%S' | strftime }}"

  - name: Take Backup when dest_path and source path are the same.

    shell: cp -ar /tmp/x "/tmp/x.{{ tdate }}"



There is no sane reason to use the shell module. This will work with the 
command module
as well.

Regards
Racke

On Monday, January 18, 2021 at 12:46:58 AM UTC-5 [email protected] wrote:

The actual folder had 777 permissions as seen below:

drwxrwxrwx 3 destuser destuser 29 Jan 14 08:40 /tmp/mohtas/folder
**//___^
I took the backup using the below playbook and wanted to preserve the 
permissions i.e 777 for the backup folder
`/tmp/mohtas/folder.bkp.15Jan2021_090700`
**//___^
---
 - name: "Play 3"
   hosts: all
   user: destuser
   tasks:
     - set_fact:
         tdate: "bkp.{{ '%d%b%Y_%H%M%S' | strftime }}"

     - name: Take Backup when dest_path and source path are the same.
       ignore_errors: yes
       copy:
         src: "/tmp/mohtas/folder"
         dest: "/tmp/mohtas/folder.{{ tdate }}"
         mode: preserve
**//___^

However, the backup folder was created with a different permissions as below:

drwxr-xr-x 3 destuser destuser 17 Jan 15 09:07 
/tmp/mohtas/folder.bkp.15Jan2021_090700

I understand that I can use statmodule but was looking for a better/quicker 
solution as i'm dealing with a loop of
files/folders.
**//___^
My ansible version is:
[destuser@desthost /]$ ansible --version ansible 2.4.2.0 config file = 
/home/destuser/.ansible.cfg configured module
search path = [u'/home/destuser/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules'] ansible python
module location = /usr/lib/python2.7/site-packages/ansible executable location 
= /bin/ansible python version = 2.7.5
**//___^
Note: The strange thing is the backup permissions are preserved if i mention
src: /tmp/mohtas/file.txtas a file and not a directory.
**//___^**//___^**//___^**//___^**//___^

--
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
[email protected] 
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b857c2f2-cf3c-4295-95b4-97442dad7d6an%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/b857c2f2-cf3c-4295-95b4-97442dad7d6an%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/OmXsuyDV_PA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13b38bbd-d001-773e-a993-1966ecc9ca94%40linuxia.de.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/62dd39aa-0ce9-4b88-958c-b8a313d0e2e1%40Spark.

Reply via email to