Module Copy-Does not handle sparse files properly

105 views
Skip to first unread message

Eric Wedaa

unread,
Oct 5, 2014, 6:52:39 PM10/5/14
to ansible...@googlegroups.com
I just found out that Ansible does not handle Sparse Files (A file with true empty space inside it) properly with the copy module.  I don't think this is a bug, but somebody should mention this in the documentation.

http://en.wikipedia.org/wiki/Sparse_file

Code to make a sparse file

#!/usr/bin/perl
## Code Blatantly stolen from Elizabeth Zwicky
#
open (HOLEYFILE, ">filewithbighole") ||
    warn "Can't create filewithbighole\n";

    select (HOLEYFILE);
    $| = 1;
    select (STDOUT);

    seek (HOLEYFILE, 1024* 1024 * 1024, 0);
    print HOLEYFILE "After the hole\n";

    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat HOLEYFILE;

    if ($blocks * $blksize == $size) {
        warn "My holey file had no holes!\n";
    }

    close HOLEYFILE;


Ansible command

 
ansible AIX-7.1 -m copy -a "src=/home/ME/filewithbighole dest=/tmp/filewithbighole"

It fails as running out of disk space. It's not a big deal as there are workarounds, like tar-ing up the file with the -S option to efficiently handle Sparse files.


[ME@ansible ~]$ ls -l filewithbighole
-rw-r--r--. 1 urew users 1073741839 Oct 5 18:44 filewithbighole

[ME@ansible ~]$ du -k filewithbighole
4 filewithbighole

[ME@ansible ~]$ !tar
tar -Scf filewithbighole.tar ./filewithbighole

[ME@ansible ~]$ ls -lt filewithbighole.tar
-rw-r--r--. 1 urew users 10240 Oct 5 18:48 filewithbighole.tar

[ME@ansible ~]$ du -k filewithbighole.tar
12 filewithbighole.tar


>>>>Ericw

Michael DeHaan

unread,
Oct 6, 2014, 8:30:35 AM10/6/14
to ansible...@googlegroups.com
Yeah I don't think we need to add specific sparse file handling to Ansible.

Ansible basically does a scp/sftp, so if those tools understand sparse files, it may be a matter of passing a flag or something, and we'd be open to patches for something like that I guess, if it were automatically detectable or reasonably safe to pass.

--
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/5928585b-e458-4e0c-b9a4-fc056a3164f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Wedaa

unread,
Oct 6, 2014, 10:42:13 AM10/6/14
to ansible...@googlegroups.com
I just think a note needs to be made in the documentation about it, and call it good.

>>Ericw
Reply all
Reply to author
Forward
0 new messages