From 84152fec3f47a0f0eab519655ebfb976c68d5a5b Mon Sep 17 00:00:00 2001 From: Dylan Martin Date: Mon, 21 Oct 2013 16:10:55 -0500 Subject: [PATCH] unarchive - mvd docs to top of file --- library/files/unarchive | 78 +++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/library/files/unarchive b/library/files/unarchive index bed545c528f..bd62bc9372b 100644 --- a/library/files/unarchive +++ b/library/files/unarchive @@ -19,6 +19,46 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +DOCUMENTATION = ''' +--- +module: unarchive +short_description: Copies archive to remote locations and unpacks them +description: + - The M(unarchive) module copies an archive file on the local box to remote locations and unpacks them. +options: + src: + description: + - Local path to archive file to copy to the remote server; can be absolute or relative. + required: true + default: null + dest: + description: + - Remote absolute path where the archive should be unpacked + required: true + default: null +author: Dylan Martin +todo: + - detect changed/unchanged for .zip files + - handle common unarchive args, like preserve owner/timestamp etc... +notes: + - requires tar/unzip command on host + - can handle gzip, bzip2 and xz compressed as well as uncompressed tar files + - detects type of archive automatically + - uses tar's --diff arg to calculate if changed or not. If this arg is not + supported, it will always unpack the archive + - does not detect if a .zip file is different from destination - always unzips + - existing files/directories in the destination which are not in the archvie + are not touched. This is the same behavior as a normal archive extraction + - existing files/directories in the destination which are not in the archvie + are ignored for purposes of deciding if the archive should be unpacked or not +''' + +EXAMPLES = ''' +# Example from Ansible Playbooks +- unarchive: src=foo.tgz dest=/var/lib/foo +''' + + import os # class to handle .zip files class _zipfile(object): @@ -96,44 +136,6 @@ class _tarxz(_tgzfile): self.module = module self.zipflag = 'J' -DOCUMENTATION = ''' ---- -module: unarchive -short_description: Copies archive to remote locations and unpacks them -description: - - The M(unarchive) module copies an archive file on the local box to remote locations and unpacks them. -options: - src: - description: - - Local path to archive file to copy to the remote server; can be absolute or relative. - required: true - default: null - dest: - description: - - Remote absolute path where the archive should be unpacked - required: true - default: null -author: Dylan Martin -todo: - - detect changed/unchanged for .zip files - - handle common unarchive args, like preserve owner/timestamp etc... -notes: - - requires tar/unzip command on host - - can handle gzip, bzip2 and xz compressed as well as uncompressed tar files - - detects type of archive automatically - - uses tar's --diff arg to calculate if changed or not. If this arg is not - supported, it will always unpack the archive - - does not detect if a .zip file is different from destination - always unzips - - existing files/directories in the destination which are not in the archvie - are not touched. This is the same behavior as a normal archive extraction - - existing files/directories in the destination which are not in the archvie - are ignored for purposes of deciding if the archive should be unpacked or not -''' - -EXAMPLES = ''' -# Example from Ansible Playbooks -- unarchive: src=foo.tgz dest=/var/lib/foo -''' # try handlers in order and return the one that works or bail if none work def pick_handler (src,dest,module): handlers = [_tgzfile, _zipfile, _tarfile, _tarbzip, _tarxz]