Commit graph

43 commits

Author SHA1 Message Date
Lucas Costa Beyeler
5559e6a669 Fix #4202: Can't unarchive remote files (#4244)
When you try to remote unarchive files with the option copy=no the code always fail, as evidenced in issue #4202. That happens because the conditional to check "if remote_src=no or copy=yes" will always be true since the default value of them is remote_src=no and copy=yes.
My modification is only to change the condition from or to and, that way only if both the vars stay with the default value will be true, otherwise you can unarchive remote files.
2016-08-11 11:23:29 -07:00
Dag Wieers
4fddb21980 Improve the documentation (#4385)
Improvements to make it more clear that pure compressed files (.gz, .bz2 and .xz) files are not supported.

This improves on #3241.
2016-08-11 08:53:37 -04:00
Sam Doran
06e9dc5236 Improve regexp for matching file permissions (#4306)
A capital "S" appears when the the setuid or setgid bit are set but have no effect. Likewise, a capital "T" appears when the sticky bit is set but it has no effect.
2016-08-10 23:54:29 +02:00
Ryan S. Brown
3a04ec5a70 Indent unarchive module documentation to fix parsing error. 2016-07-14 14:05:00 -04:00
James Cammarata
467516e5da Add remote_src param for unarchive to deprecate copy param
From ansible/ansible#10218
2016-07-14 11:24:23 -05:00
Dag Wieers
37b7708c5d Fix a problem where the newly provided mode is a string (#3769)
* Fix a problem where the newly provided mode is a string

This fixes #3597

* Implement python3-compatible get_exception() handling
2016-07-06 15:16:51 -07:00
Dag Wieers
b66bf8e7a4 Revert PR #3575 since it causes problems related to exclude patterns (#3767)
* Revert PR #3575 since it causes problems related to exclude patterns

By using a different method for getting archive filelists, and extracting we introduced new problems related to excluding based on gtar patterns.

As a result files that would be excluded by gtar, would still be in the filelist. Implementing our own gtar compatible pattern exclusion mechanism is near to impossible (believe me, we looked at it...). The best way is to look at the original problem and deal with that, and ensure that extraction and filelists are done with the exact same tool and exact same options.

The solution is to decode the octal unicode representation in gtar's output back to unicode. Since gtar has no problem extracting these files in LANG=C, we simply has to compensate for it.

This reverts #3575 and fixes #11348.

* Implement codecs.escape_decode() instead of decode("string_escape") for python3
2016-07-06 14:40:48 -07:00
Toshio Kuratomi
41adb78cab A few more sanity checks for detecting unzip output that's not a file entry (#3982)
* A few more sanity checks for detecting unzip output that's not a file entry

Also note that there's a rounding error somewhere in the mtime
comparison code.

* Fix reference to sub-array
2016-06-27 13:18:12 -07:00
neo
606598a857 fix unarchive doesn't extract changed tar file #3901 2016-06-10 17:35:08 -04:00
Dag Wieers
3f7a935932 Improve the unzip output scraping (#3819)
* Improve the unzip output scraping

Ensure we capture the complete file (also when it includes spaces).
Drop lines that do not conform (in length) to what we expect (e.g. header/footer).

This fixes #3813

* Fix how split() works
2016-06-10 11:05:22 -04:00
Jan Fader
7c08f10900 fix for #3706 (#3778) 2016-05-29 06:52:18 -07:00
Dag Wieers
9f973aefb1 Add unpack results to error output, for debugging purposes on failure
This may help understand what is going on with #3631
2016-05-26 18:43:22 -07:00
Toshio Kuratomi
ca4140134d Python2.4's zipfile library cannot handle zip 64bit extensions which are needed for > 64K files (#3754)
Fallback to unzip if zipfile fails and hope that unzip can deal with it
(sites have an easier time upgrading the unzip utility than all of
python).

https://bugs.python.org/issue3997

Fixes #3560
2016-05-26 16:40:50 -07:00
Michael Scherer
69ea617093 Convert the whole files/ directory to py3 syntax (#3685) 2016-05-18 07:01:53 -07:00
Dag Wieers
83a3c45a7d Fix small typo (#3642) 2016-05-13 13:10:35 -04:00
Veaceslav Mindru
430e3eeebd add vlidate_certs option for unarchive module (#2635) 2016-05-05 11:25:40 +02:00
Toshio Kuratomi
4a8a292793 bytearray isn't available in python2.4 (#3583)
* Detection of handler depends on the wrong handler failing to list the contents of the tarfile.

Use explicit compression types with the python tarfile library to
achieve that.

* bytearray isn't available in python2.4
2016-05-02 11:29:04 -07:00
Toshio Kuratomi
0ec3b06208 Detection of handler depends on the wrong handler failing to list the contents of the tarfile. (#3584)
Use explicit compression types with the python tarfile library to
achieve that.
2016-05-02 11:27:44 -07:00
Virgil Dupras
82aeaed45d unarchive: use Python's tarfile module for tar listing (#3575)
* unarchive: use Python's tarfile module for tar listing

fixes https://github.com/ansible/ansible/issues/11348

Depending on the current active locale, `tar`'s file listing can end up
spitting backslash-escaped characters. Unfortunately, when that happens,
we end up with double-escaped backslashes, giving us a wrong path,
making our action fail.

We could try un-double-escaping our paths, but that would be complicated
and, I think, error-prone. The easiest way forward seemed to simply use
the `tarfile` module.

Why use it only for listing? Because the `unarchive` option also
supports the `extra_opts` option, and that supporting this would require
us to mimick `tar`'s interface.

For listing files, however, I don't think that the loss of `extra_opts`
support causes problems (well, I hope so).

* unarchive: re-add xz decompression support

Following previous change to use Python's `tarfile` module for tar file
listing, we lost `xz` decompression support. This commits re-add it by
adding a special case in `TarXzArchive` that pre-decompresses the source
file.
2016-05-01 17:34:43 -07:00
Dag Wieers
983cdd00bc Making unarchive idempotent (#3307)
* WIP: Making unarchive idempotent

Currently unarchive is not idempotent and has many rough edges and bugs.
The current release is a workable improvement on many fronts:

- zip support is now idempotent (but gtar lacks check-mode)
- New option `exclude` to exclude specific paths/files
- New option `keep_newer` to exclude newer files on target
- New option `extra_opts` to influence unzip/gtar (like synchronize module)

The following items are still ongoing:

- Implement CRC32 support for .zip files
- Re-implement the zip support using native zipfile module
- Re-implement the gtar support using native tarfile/gzip/bz2 modules (lzma external)
- Implement check-mode (works in gzip, but fails using gtar)
- Implement diff-mode (discuss an appropriate output model, like synchronize module)

The re-implementation of unzip/gtar support using native python modules will not only simplify the codebase, additional functionality can be implemented correctly and identically, which is currently not possible. (Other archives could be implemented using native modules equally, incl. options)

* Assorted fixes to zip support (during quality checks)

- Support both rw---- and rwx--- permstr
- Better file type support (more qa needed)
- Symlink support
- Include fix from #3229

* Implement zip diff-mode (itemized change) and avoid changes permissions every time (!)

This commit implements:
- rsync-compatible itemized-change output in diff-mode (using zip)
- no longer changing permissions unconditionally (when idempotent)

* Small fixes to itemized change output

* Fixes to user/group ownership changes

- The implementation of user/group ownership is a bit more complex for idempotency
- We report when a ZIP file incorrectly tags a directory as a file/link
- We only offer diff output when there is a change

* Fix the handling of includes and excludes for unzip

* Remove test output from output (confuses easily)

* Logic and performance improvements to ownership handling, and umask fix

* Handle special files (type '?')

* Make exceptions compatible with python 2.4

* Implement CRC32 support

* Revert some unintended/unknown changes ?

* Taking over maintenance as offered by current maintainer

* Fix support for white-spaces in filenames

* Remove/rename incorrect regex

* Ensure that fat executables end up with execute permission

* Remove check_result from output when unchanged

* When unarchiving as a user, or when owner/group/mode is supplied --diff is insufficient

Only way to be sure is to check request with what is on disk (as we do for zip).
Leave this up to set_fs_attributes_if_different() instead of inducing a (false) change

* By default, don't send confusing check_results in verbose output

This fixes #74.
2016-04-18 16:31:06 -04:00
Dag Wieers
7cd47eb73a Ensure that a download failure is properly raised before the read fails
Without this change, a download failure may bail out with the message:

    "Failure downloading http://foo/bar, 'NoneType' object has no attribute 'read'"

whereas with this fix, you'd get a proper error like:

    "Failure downloading http://foo/bar, Request failed: <urlopen error [Errno 113] No route to host>"

or one of the many other possible download errors that can occur.
2016-03-08 01:19:23 +01:00
Toshio Kuratomi
832e81e691 Set some module parameters to type=path 2016-02-29 00:21:02 -08:00
Dylan Martin
bfa7cdb5c4 improved error message when no handler found 2015-11-30 11:47:38 -08:00
Brian Coca
f12a2135ca Merge pull request #1525 from mjuenema/devel
Removed check whether destination directory is writable from files/un…
2015-09-14 09:01:36 -04:00
Brian Coca
e916b04e91 Also document in example that unarchive download was added in 2.0 2015-07-14 10:19:17 -04:00
verm666
8deee99fcc unarchive: fix @bcoca's remarks, issue #1575 2015-06-30 08:14:30 -07:00
verm666
725a7b2f59 unarchive: fix work with 0 bytes archives
This change is in response to issue #1575
2015-06-26 05:49:59 -07:00
Toshio Kuratomi
c5324f54e6 Bump amount of file to download in a chunk to 64k. 2015-06-24 06:48:57 -07:00
Toshio Kuratomi
daa1472ccf Merge pull request #1448 from Jmainguy/unarchive_http
add download ability to unarchive module
2015-06-24 06:44:58 -07:00
Jonathan Mainguy
58ef71fc84 add download ability to unarchive module 2015-06-23 22:14:25 -04:00
Markus Juenemann
0db3206cae Removed check whether destination directory is writable from files/unarchive.py.
This check will prevent extraction of an archive if the archive does not
actually write to the destination directory but only writes to any writable
sub-directories of it. The underlying tar command will report errors
should it try to write to read-only directories.
2015-06-16 10:37:38 +10:00
Greg DeKoenigsberg
2a5f0bde87 Proper author info for all remaining modules 2015-06-15 15:53:30 -04:00
Brian Coca
9a2e64b76d generic fix for Exceptions that heppen when trying to set permissions on extracted files
fixes ansible/ansible#10934 which is really a corner case
2015-05-11 13:18:05 -04:00
Toshio Kuratomi
a19fa6ba48 Implement feature to return list of files in the archive 2015-04-15 09:25:23 -07:00
Toshio Kuratomi
761fc8d277 Tar --diff only sends output to stderr if a file is missing. Handle that case
Fixes #1064
2015-04-15 05:05:41 -07:00
mrsheepuk
410862d631 Doc change - make clearer usage for existing remote file
Having read the doc for this module several times and completely missing that it can be used for existing remote archives, I propose this update to the wording to make clear from the top the two ways in which this module can be used.
2015-02-17 13:48:59 +00:00
Toshio Kuratomi
99a8caf409 Prefer gtar to tar
Fixes #702
2015-01-26 09:46:53 -08:00
Toshio Kuratomi
9f333afb6a Standardize class names on Archive suffix.
This also removes the collision between the stdlib ZipFile class and the
module's ZipFile class

Fixes #681
2015-01-21 16:15:42 -08:00
Toshio Kuratomi
e3759bd0d3 Add detection of uid,gid,mode changes when deciding whether an archive
needs to be unarchived again.
2015-01-14 19:20:07 -08:00
Toshio Kuratomi
6159b5c423 Implement user,group,mode,selinux settings for unarchive.
This is a partial fix for #234.  Still have to figure out how to
make change reporting work as we can no longer rely on tar's --compare
option
2015-01-14 13:11:33 -08:00
Jon Hadfield
9e0565e58f Remove redundant check for creates argument. 2014-10-03 13:00:11 +01:00
James Cammarata
cb69744bce Adding file doc fragment to those modules in files/ missing it 2014-10-01 20:55:50 -05:00
Michael DeHaan
c8e1a2077e file extensions! 2014-09-26 10:37:56 -04:00
Renamed from files/unarchive (Browse further)