unarchive - mvd docs to top of file

reviewable/pr18780/r1
Dylan Martin 11 years ago
parent d4a9e54f26
commit bc2b826fc4

@ -19,6 +19,46 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
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]

Loading…
Cancel
Save