archive-extracted

Example:

# Extract tar.gz archive, changing owner.
- archive-extracted:
    src: /tmp/archive.tar.gz
    dest: /tmp/archive-restore
    owner: freckles
    mode: '0700'

Description

Extracts an archive into a given location. Makes sure the parent folder of this location exists, as well as an optionally specified owner/group of the extracted archive.

When using this, make sure the required 'unarchive' tools (like 'unzip', 'bzip2', etc) are installed already on the target system.

Resources

Variables

Name Type Default Description

dest

string --

The remote absolute path where the archive should be unpacked. Required

src

string --

If remote_src=no (default), local path to archive file to copy to the target server; can be absolute or relative. If remote_src=yes, path on the target server to existing archive file to unpack. If remote_src=yes and src contains ://, the remote machine will download the file from the URL first. (version_added 2.0). This is only for simple cases, for full download support use the get_url module. Required

creates

string --

If the specified absolute path (file or directory) already exists, this step will not be run.

group

string --

The group of the folder, will be created if necessary.

keep_newer

boolean False

Do not replace existing files that are newer than files from the archive.

mode

string --

Mode the file or directory should be. For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like 0644 or 01777) or quote it (like '644' or '1777') so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of version 1.8, the mode may be specified as a symbolic mode (for example, u+rwx or u=rw,g=r,o=r).

owner

string --

The owner of the folder, will be created if necessary.

parent_dir_mode

string --

The permissions of the parent directory.

remote_src

boolean False

Set to yes to indicate the archived file is already on the remote system and not local to the Ansible controller.

Examples

Example 1

Extract tar.gz archive, changing owner.

Code
- archive-extracted:
    src: /tmp/archive.tar.gz
    dest: /tmp/archive-restore
    owner: freckles
    mode: '0700'
Description

Extracts the archive file '/tmp/archive.tar.gz' into the folder '/tmp/archive-restore' and sets the target folder mode to '0700'. Creates the 'freckles' user if it doesn't exist yet. if it doesn't exist yet.

Example 2

Extract zip archive.

Code
- archive-extracted:
    src: /tmp/archive.zip
    dest: /tmp/archive-restore
Description

Extracts the zip file '/tmp/archive.zip' into the folder '/tmp/archive-restore'.

Command-line

frecklecute archive-extracted --help

Usage: frecklecute archive-extracted [OPTIONS]

  Extracts an archive into a given location. Makes sure the parent folder of
  this location exists, as well as an optionally specified owner/group of
  the extracted archive.

  When using this, make sure the required 'unarchive' tools (like 'unzip',
  'bzip2', etc) are installed already on the target system.

Options:
  --dest DEST                     The remote absolute path where the archive
                                  should be unpacked.  [required]
  --src SRC                       The path/url to the archive.  [required]
  --creates CREATES               If the specified absolute path (file or
                                  directory) already exists, this step will
                                  not be run.
  --group GROUP_NAME              The group of the folder, will be created if
                                  necessary.
  --keep-newer / --no-keep-newer  Do not replace existing files that are newer
                                  than files from the archive.
  --mode MODE                     The permissions of the extracted archive.
  --owner USER_NAME               The owner of the folder, will be created if
                                  necessary.
  --parent-dir-mode MODE          The permissions of the parent directory.
  --remote-src / --no-remote-src  Whether the src file is remote.
  --help                          Show this message and exit.