Commit Graph

405 Commits (de2096e3d01af9aba45cccc02391c390ca2fc330)

Author SHA1 Message Date
Sam Doran d3e7d4f469 Change example syntax on replace module 2016-12-08 11:25:29 -05:00
Sam Doran 25f6f36a92 Change examples syntax on lineinfile module 2016-12-08 11:25:29 -05:00
Sam Doran 1923666b22 Change examples syntax on ini_file module 2016-12-08 11:25:29 -05:00
Sam Doran ba76df1af1 Change examples syntax on find module 2016-12-08 11:25:29 -05:00
Sam Doran 0c46813871 Change examples syntax on file module 2016-12-08 11:25:29 -05:00
Sam Doran 6ea87c583b Change examples syntax on fetch module 2016-12-08 11:25:29 -05:00
Sam Doran 532c77849a Change examples syntax on copy module 2016-12-08 11:25:29 -05:00
Sam Doran 8f097580ec Change examples syntax on assemble module 2016-12-08 11:25:28 -05:00
Sam Doran c694fe6ca4 Change examples syntax on acl module 2016-12-08 11:25:28 -05:00
Brian Coca 847cc0a1ec Revert "stat: doc: add version for new returns" 2016-12-08 11:25:28 -05:00
Brian Coca 50c9a276d7 added file flags/attributes to stat (#5358)
depends on http://github.com/ansible/ansible/issue/18213
also documented return version of fields added in 2.2
added get_mime to keep consistency
changed default mime behaviour
2016-12-08 11:25:28 -05:00
Gyorgy Szombathelyi 33ef72b584 Ini_file: fix regression with the create option
The new create option with the default value 'no' changes the
behavior from the previous Ansible releases. Change the default to
'yes' to create missing ini files by default.

Fixes: #5488
2016-12-08 11:25:28 -05:00
René Moser c8da9b012b stat: doc: add version for new returns (#5594) 2016-12-08 11:25:28 -05:00
Michael Herold e5cc4a45d3 Removes outdated "requirement" and outdated "note" (#5332)
- 7f59773460d79b3dae34c375ba68caea1bfc09a8 no longer uses `ConfigParser`
- 1d4c0abe2902d91b2895452feedcf72bf3dd9e20 removed the `import` statement
2016-12-08 11:25:26 -05:00
zuiurs eeecc3adcc fix the behavior that the dest is directory
This fixes the behavior that the dest is directory,
when we set the "force: no" argument.
To be join the dest and the src's basename,
before checking the "force" argument.
2016-12-08 11:25:25 -05:00
bencomp d25ba6a30a Make find return sample a YAML dict
In the description of the find module return value, the sample dict
has its key=value strings converted to key=value: None in the
web documentation. This commit updates the sample output to a 'real'
dict.

Minor additional edit in the description: "return list *of* files".
2016-12-08 11:25:24 -05:00
Evan Kaufman 42079bcc59 Exposed backup file path, simplified result args (#5364)
Fixes #245
2016-12-08 11:25:24 -05:00
Timothy Appnel 5a17277bd3 clarifies synchronize module on use of --delayed-updates 2016-12-08 11:25:24 -05:00
Luca Berruti 2bbbf58156 ini_file: return more infos on changes. 2016-12-08 11:25:23 -05:00
Luca Berruti 6d8b140f46 ini_file: diff support. 2016-12-08 11:25:23 -05:00
Luca Berruti 73401182c1 ini_file: add create= option. 2016-12-08 11:25:23 -05:00
Luca Berruti 1a22dde1ac ini_file: fixes #1788, fails --check when file doesn't exist. 2016-12-08 11:25:23 -05:00
Brian Coca fccaf883da refactor stat
make format function 'format only'
added platform dependant info, when it is available
avoid rechecking same info
added comments to each info gathering section

(cherry picked from commit a79acf73d7eb79b76d808ff8a1d6c505dfd9ec82)
2016-12-08 11:25:23 -05:00
Charles Zaffery 4c830400f8 Remove line when 'state: absent' with 'option:' instead of commenting 2016-12-08 11:25:23 -05:00
Michael Scherer 3f43879db8 Cleanup imports of xattr
Since the module use re and os, we need to import them.
And rather than importing '*', we should limit to the
only object/function needed, so we can more easily refactor
later.
2016-12-08 11:25:21 -05:00
Michael Scherer a567942405 Fix unarchive on python3
Since handler.files_in_archive is a list of files coming from
various executables output, that's a bytes list, and we use it
with dest who is a str. So we need to convert that to native
type.
2016-12-08 11:25:20 -05:00
John R Barker 25b6492d37 Bulk spelling improvement to modules-core (#5225)
* Correct spelling mistakes

* Correct more spelling issues

* merge conflict

* Revert typo in parms
2016-12-08 11:25:20 -05:00
Toshio Kuratomi 007b5f4c32 Fix assemble module for python3 2016-12-08 11:25:18 -05:00
Matt Clay 25d829c8f2 Detect tar type (bsd, gnu) and only use gnu tar. (#4352)
* Detect tar type (bsd, gnu) and only use gnu tar.

* Revert return code checking for TgzArchive.
2016-12-08 11:25:14 -05:00
Andrew Gaffney 460b0e1ab6 Match existing INI file entry with leading whitespace (fixes #4997) (#4998) 2016-12-08 11:25:13 -05:00
JesseEmond 6ddbc63b1d Unarchive stop passing file mode to tar command (#4179)
Fixes #4063.

Tar does not use this parameter on extraction (-x) or diff (-d)(the
only two cases where it is passed in unarchive). It only uses it on
creation:
https://www.gnu.org/software/tar/manual/html_section/tar_33.html

Providing `unarchive` with a file mode of `0755` (octal) makes it pass
the argument `--mode 493` (493 = 0755 in decimal) to `tar`, which then
fails while verifying it (because it contains an invalid octal char
'9'). Not passing the parameter to tar solves the issue.
2016-12-08 11:25:12 -05:00
nichivo c4f43eb965 Insert missing option line before blank lines (#4747) 2016-12-08 11:25:10 -05:00
Brian Maddy 7ca911d345 typo in stat.executable (was stat.excutable) (#4886)
I didn't actually run this because it's so simple, but it seems correct.
2016-12-08 11:25:09 -05:00
Dag Wieers 433dfd0c5b Don't add included files as arguments on the command line (#4626)
This means we will have to unarchive the complete archive if a single change is found.
Unfortunately we cannot fix this for `unzip`, the only hope is a pure-python reimplementation.

This fixes problems reported in the comments of #3810
2016-12-08 11:25:04 -05:00
Dag Wieers 976d876e55 Ensure unicode characters in zip-compressed filenames work correctly (#4702)
* Ensure unicode characters in zip-compressed filenames work correctly

Another corner-case we are fixing hoping it doesn't break anything else.

This fixes:
- The correct encoding of unicode paths internally (so the filenames we scrape from the output and is returned by zipfile match)
- Disable LANG=C for the unzip command (because it breaks the unicode output, unlike on gtar)

* Fix for python3 and other suggestions from @abadger
2016-12-08 11:25:03 -05:00
Brian Coca a42cb96b75 added backup_file to module returns (#4723)
fixes #14502
also cleaned up some unused stuff and fixed imports
2016-12-08 11:25:02 -05:00
Dag Wieers 5995097e61 Support DOS file attributes (e.g. archive-bit or hidden-bit) (#4705)
This fixes #4554
2016-12-08 11:25:02 -05:00
Evan Kaufman 77f5472a53 Declare empty diff dict ahead of time (#4646)
Fixes #4634
2016-12-08 11:24:59 -05:00
Toshio Kuratomi 69ec272982 Python3 fixes to copy, file, and stat so that the connection integration tests can be run (#4632)
* Python3 fixes to copy, file, and stat so that the connection integration tests can be run

* Forgot to audit the helper functions as well.

* Fix dest to refledt b_dest (found by @mattclay)
2016-12-08 11:24:59 -05:00
Toshio Kuratomi 45846127c5 to_text, to_bytes, and to_native now have surrogate_or_strict error handler (#4630)
On python3, we want to use the surrogateescape error handler if
available for filesystem paths and the like.  On python2, have to use
strict in these circumstances.  Use the new error strategy for to_text,
to_bytes, and to_native that allows this.
2016-12-08 11:24:57 -05:00
Evan Kaufman 254df9bcca Implemented file content diff for replace module (#4479) 2016-12-08 11:24:54 -05:00
James Pharaoh 06f5f2e26d fix error in documentation for stat checksum (#4582) 2016-12-08 11:24:54 -05:00
Gennady Trafimenkov 7ea7564bf4 Clarify what checksum algorithm is used by copy modules (#4198) 2016-12-08 11:24:54 -05:00
Toshio Kuratomi c4988262b5 Fixes for lineinfile (#4553)
Lineinfile deals heavily with Unic text files.  Makes some sense to deal
with it all as byte strings.  So there is a lot of work done here to
show that we're dealing with byte strings throughout.
2016-12-08 11:24:53 -05:00
Dag Wieers 32e3cc7778 Fix multiple issues with unzip and gtar support (#4131)
* Improve the correct handling of gtar and unzip options

Add the option --show-transformed-names when extra_opts is being used
Ignore bogus warnings related to empty filenames
Properly quote _and_ escape filenames for unzip command
Rewrite gtar options and provide run_command with array, not string

This fixes #2480 and #4109.

* Make check-mode work for zip-files

Check-mode was disabled for zip-files since gtar did not support it.
This change enables check-mode support for zip-files, but does skip the task when used with gtar.
(Best of both worlds)

Also remove unused compress_mode variable.

This replaces PR #4401, the changes overlap somewhat so I merged them
2016-12-08 11:24:53 -05:00
Michael Scherer 441205feed Add acl freebsd (#3656)
* FreeBSD do not support --omit-header and --absolute-names

* The option for following symlink wth getfacl is different on FreeBSD

* ZFS on Freebsd use nfsv4 acls, who use a slightly different syntax

* FreeBSD do not have a --test flag, so always return 'True'

* FreeBSD do not have the --omit-headers options, so we have to filter by ourself

* Mark Freebsd as working for the acl module
2016-12-08 11:24:52 -05:00
Toshio Kuratomi 07e79ac683 Refactor stat.py so that it would be more friendly for unittests. (#4462)
* Refactor stat.py so that it would be more friendly for unittests.

* PEP8ify since we're moving most of the lines in the file and there's no open PRs
2016-12-08 11:24:51 -05:00
Chris Short 8ffe5c3c54 find.py: Editing contains description to say regex (#4452)
find module contains argument appears to accept regex; correcting description accordingly
2016-12-08 11:24:51 -05:00
Lucas Costa Beyeler 6aeea1fe7e 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-12-08 11:24:49 -05:00
Dag Wieers fe273a4e09 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-12-08 11:24:49 -05:00
Sam Doran 4c6cfb9eec 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-12-08 11:24:49 -05:00
Brian Coca 81e87cefd7 unsafe writes! (#4314)
* unsafe writes!

* moved unsafe_write docs and args to file common

* added unsafe_writes option handling
2016-12-08 11:24:49 -05:00
Toshio Kuratomi c5052f9b01 Be explicit about specifying the ssh port if it was user specified (#4302)
Previously, if the port specified by the user or inventory was 22, then
the ssh client port would be used instead.

Fixes #3895
2016-12-08 11:24:48 -05:00
peter.jang b06f3bbb22 fix for rsync protocol (#4211) 2016-12-08 11:24:47 -05:00
David Chwalisz f979928ecc file module: add clarification on state=absent re files that do not exist. 2016-12-08 11:24:46 -05:00
Brian Coca 544b044129 stop trying to set permissions in check mode
fixes #4195
2016-12-08 11:24:44 -05:00
Ryan S. Brown 9336e0d070 Indent `unarchive` module documentation to fix parsing error. 2016-12-08 11:24:44 -05:00
tobixx ed1d80b7d8 added read-/write-/executeable flags for invoking user (#4130) 2016-12-08 11:24:44 -05:00
James Cammarata aa1e9e3d5f Add remote_src param for unarchive to deprecate `copy` param
From ansible/ansible#10218
2016-12-08 11:24:44 -05:00
Dag Wieers 017eeaea29 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-12-08 11:24:42 -05:00
Dag Wieers 855ca9b204 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-12-08 11:24:42 -05:00
Lukas Grossar 4a532fb60c also match on tabs in ini_file (fixes #106) (#4067)
also match on tabs in ini_file
2016-12-08 11:24:41 -05:00
Toshio Kuratomi 30399d94f6 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-12-08 11:24:40 -05:00
Keisuke Kamada 259c4b31fb Do not copy file if running on check mode 2016-12-08 11:24:38 -05:00
Brian Coca 1f6c3766b0 restored incorrectly removed docs, jinja2 override 2016-12-08 11:24:37 -05:00
neo 07c8804486 fix unarchive doesn't extract changed tar file #3901 2016-12-08 11:24:36 -05:00
Matt Fischer a28b23db86 Update delete notes for Synrhconize docs (#3723)
The example for delete=yes does not specify recursive although it is
required. In addition, the wording for the delete option is confusing
about from where files are really deleted. This should clarify that.
2016-12-08 11:24:36 -05:00
Dag Wieers c6fb3ceb85 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-12-08 11:24:36 -05:00
Brendan Jurd c5fbda395b Fix grammar in docs for fetch 'fail_on_missing' (#3872) 2016-12-08 11:24:35 -05:00
Brian Coca 73bc9fd0e0 Revert "Add prefixing and suffixing fuctionality to assemble"
This reverts commit 4c386dba565109d971e88be961abe93d700939b3.
keeping in sync with main repo revert
2016-12-08 11:24:33 -05:00
Matthias Frey d5fc44610b Fixed error in assemble module when validation failed. (#3814)
Error was: TypeError: fail_json() takes exactly 1 argument (2 given)
2016-12-08 11:24:33 -05:00
Jan Fader 3afbe28b8a fix for #3706 (#3778) 2016-12-08 11:24:32 -05:00
Dag Wieers f7fcb81dd9 Add unpack results to error output, for debugging purposes on failure
This may help understand what is going on with #3631
2016-12-08 11:24:31 -05:00
Toshio Kuratomi 286a46e8b4 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-12-08 11:24:31 -05:00
Marcos Diez 366d52cf18 The documentation of lineinfile now makes reference to blockinfile (#3639) 2016-12-08 11:24:30 -05:00
Michael Scherer f7b29ba8fd Convert the whole files/ directory to py3 syntax (#3685) 2016-12-08 11:24:29 -05:00
Michael Scherer f423554e20 Testing the module on freebsd fail, since module is not assigned yet 2016-12-08 11:24:28 -05:00
Michael Scherer 98c729bfd7 Fix the argument for acl module (#3653) 2016-12-08 11:24:28 -05:00
Dag Wieers c650f06b03 Fix small typo (#3642) 2016-12-08 11:24:28 -05:00
Veaceslav Mindru 8c6af73218 add vlidate_certs option for unarchive module (#2635) 2016-12-08 11:24:26 -05:00
Toshio Kuratomi fa00c69ff2 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-12-08 11:24:26 -05:00
Toshio Kuratomi cd26cc8a0d 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-12-08 11:24:26 -05:00
Virgil Dupras 930ea5dd55 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-12-08 11:24:26 -05:00
Dag Wieers 356d9a272a Replace ansible_hostname with inventory_hostname (#3559)
This way these examples can be re-used using the ansible command (and don't require facts gathering).
2016-12-08 11:24:25 -05:00
Michael Scherer 001ceb8dc6 Remove old test on SELinux (#3510)
since all is done in modules_utils/basic.py, no need to make
the same test here, especially since that's unused later
2016-12-08 11:24:20 -05:00
Dag Wieers a26188e55d 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-12-08 11:24:18 -05:00
yarick123 87fe4a2f0c ini_file: added option 'noextraspaces' to turn off inserting extra spaces around '=' symbol
* ini_file: added option 'noextraspaces' to turn off inserting extra spaces around '=' symbol

* ini_file: noextraspaces, python 2.4 compatibility

* ini_file: noextraspaces - yes/no => true/false

* ini_file: noextraspaces - added 'version_added' option

* ini_file: noextraspaces => no_extra_spaces
2016-12-08 11:24:18 -05:00
Mengdi Gao 165f48717a Improve doc accuracy of template module 2016-12-08 11:24:17 -05:00
peter.jang f7fb5e31c2 added rsync protocol support (#1999)
* added rsync protocol support

* correction for example document(add example for push on delegate)

* use startswith method for safety
2016-12-08 11:24:16 -05:00
Bence Nagy 0fd89cfd44 Add prefixing and suffixing fuctionality to assemble 2016-12-08 11:24:14 -05:00
Brian Coca 90650256ef fixed exit json 2016-12-08 11:24:11 -05:00
Matt Martz e4a88eeebe Fix synchronize docs to indicate the correct default for use_ssh_args 2016-12-08 11:24:11 -05:00
Brian Coca 9084e31979 fixes to assemble
now uses atomic move to avoid data corruption
correclty cleans up temp files in every case
returns backup_file info if needed
validate validate before temp file gets created
backup AFTER validate
2016-12-08 11:24:10 -05:00
Dag Wieers 20b7757032 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-12-08 11:24:10 -05:00
Bert Van Vreckem 4a10eeb196 Also show stdout when validation fails. This fixes #2498 2016-12-08 11:24:09 -05:00
Toshio Kuratomi 390dbe5090 Change one param to be of type path 2016-12-08 11:24:08 -05:00
Toshio Kuratomi ecafdeeaa5 Set some module parameters to type=path 2016-12-08 11:24:08 -05:00
Toshio Kuratomi cea1125d02 Correct dest_port to be of type int 2016-12-08 11:24:08 -05:00
Toshio Kuratomi 249b9511a5 Set name to type path so that tilde and env vars are expanded 2016-12-08 11:24:08 -05:00
Brian Coca a546775172 fixed typo, now correctly check isdir
fixes #3089
2016-12-08 11:24:07 -05:00
Brian Coca 69b0e39220 added missing checksum alias 2016-12-08 11:24:07 -05:00
Brian Coca 4ec0ccd5ac fixed option name mismatch, added aliases
also removed empty aliases
2016-12-08 11:24:06 -05:00
Brian Coca b357f4dd72 added follow to specific modules that support it
was removed from common file docs
2016-12-08 11:24:06 -05:00
Jose Moreira cc173b445e Fixed module doc typos 2016-12-08 11:24:06 -05:00
Brian Coca bbfb957bc1 recursive copy is not available(yet) on remote_src 2016-12-08 11:24:06 -05:00
Guruprasad 1b642fcf75 Fix typo in the copy module error message
Fix the typos in the error message shown on trying to use remote_src=yes for copying directories
2016-12-08 11:24:06 -05:00
Brian Coca 23c07ccf2c cleaner error on recursive remote copy
TODO: add recursive copy support when remote_src=yes
probably need to make shared the logic in the action plugin.
2016-12-08 11:24:06 -05:00
Brian Coca 8d0d251003 removed 'overquoting' of example
fixes #3029
2016-12-08 11:24:05 -05:00
Tobias Wolf 1ecc8544f6 Add diff for both file contents and file attributes to lineinfile
Using the difflist feature added in ansible/ansible@c337293 we can add
two diffs to the `diff` dict returned as JSON: A `before` and `after` pair of
changed file contents and the diff of the file attributes.

n.b.: the difflist handling from the above commit is logically broken.
PR will follow.

Example output:

    TASK [change line and mode] ************************************************************
    changed: [localhost]
    --- before: /tmp/sshd_config (content)
    +++ after: /tmp/sshd_config (content)
    @@ -65,21 +65,21 @@
     X11DisplayOffset 10
     PrintMotd no
     PrintLastLog yes
     TCPKeepAlive yes
     #UseLogin no

     #MaxStartups 10:30:60
     #Banner /etc/issue.net

     # Allow client to pass locale environment variables
    -AcceptEnv LANG LC_*
    +AcceptEnv        LANG LC_* GF_ENV_*

     Subsystem sftp /usr/lib/openssh/sftp-server

     # Set this to 'yes' to enable PAM authentication, account processing,
     # and session processing. If this is enabled, PAM authentication will
     # be allowed through the ChallengeResponseAuthentication and
     # PasswordAuthentication.  Depending on your PAM configuration,
     # PAM authentication via ChallengeResponseAuthentication may bypass
     # the setting of "PermitRootLogin without-password".
     # If you just want the PAM account and session checks to run without

    --- before: /tmp/sshd_config (file attributes)
    +++ after: /tmp/sshd_config (file attributes)
    @@ -1,3 +1,3 @@
     {
    -    "mode": "0700"
    +    "mode": "0644"
     }
2016-12-08 11:24:02 -05:00
Toshio Kuratomi f6aa1ff9a4 Remove duplicate documentation fields 2016-12-08 11:24:01 -05:00
Toshio Kuratomi ceba43e701 Better error message when rsync nad ssh aren't present where synchronize is run
Fixes https://github.com/ansible/ansible/issues/9305
2016-12-08 11:24:01 -05:00
Tobias Wolf 25ccb98d49 Add custom or 'prepared' diff field to synchronize module
This PR depends on pull requeest ansible/ansible#14105

rsync has a custom diff output that cannot easily be expressed as
`/usr/bin/diff before after`
2016-12-08 11:24:01 -05:00
Toshio Kuratomi 457dfb3b4b Add an internal param instructing synchronize to replace localhost with the host that's being ssh'd from 2016-12-08 11:24:01 -05:00
Matt Martz 9e686c7294 Add note about precautions of using become with fetch. Addresses https://github.com/ansible/ansible/issues/14064 2016-12-08 11:24:01 -05:00
Toshio Kuratomi 5e4fe92676 Fix documentation build 2016-12-08 11:24:01 -05:00
Toshio Kuratomi 5f35d0d597 Document that synchronize in 2.0.0.x has broken sudo behaviour.
Part of the changes for #13825
2016-12-08 11:24:01 -05:00
Brian Coca 288a5c9a77 adds diff info for file info 2016-12-08 11:23:56 -05:00
Michael Scherer 83b45ae047 Fix doc inconsistency (#2630) 2016-12-08 11:23:55 -05:00
Brian Coca 63fd67f156 added mime option to stat module
it uses file magic to now return mime_type and charset of a file as
per output of `file -i /path`
2016-12-08 11:23:53 -05:00
Adam Fields 9c131ea619 added a reference to the template module for clarity 2016-12-08 11:23:52 -05:00
quoing 3ad67d93ea Fix: Default ACL parameters are not correctly handled 2016-12-08 11:23:51 -05:00
Brian Coca f0a3914f7b simplified lowercasing 2016-12-08 11:23:50 -05:00
quoing 3a91853e7e Add "default" entry option back (removed in e95bcae), update will translate entry to standard parameters so compatibility with BDS is kept 2016-12-08 11:23:50 -05:00
Ales Nosek df4109d946 Fix #2475 ini_file module: bracklets in key break idempotence
Escape the regex special characters in the option name.
2016-12-08 11:23:50 -05:00
krdlab fe0aa01ce8 Fix 'stat' module document 2016-12-08 11:23:50 -05:00
Dylan Martin 579e444243 improved error message when no handler found 2016-12-08 11:23:50 -05:00
Brian Coca 3025451b10 fixed typo EEXISTS is actually EEXIST
fixes #2585
2016-12-08 11:23:50 -05:00
Charles Ferguson 4c93b5dab6 Add documentation to 'file' AnsibleModule definition for internals.
The parameters 'diff_peek' and 'validate' are not expected to be used
by users. They are internal. To make it clear, this change adds the
comments 'Internal use only' to each of those definitions to make
it clear that they are actually used, just not by end-users.
2016-12-08 11:23:50 -05:00
Charles Ferguson e86ba78685 Update documentation for 'file' module to include 'diff_peek'.
The 'diff_peek' option isn't documented at all, and provides a
rudimentary check that the content isn't binary. Documentation is
added to explain the option.

The 'validate' option has a declaration, but isn't implemented.
Therefore it may as well be removed from the module.
2016-12-08 11:23:49 -05:00
Charles Paul 52d499d268 create non-existent ini file
fixing fail_json

more verbose fail msg
2016-12-08 11:23:48 -05:00
Maarten Claes e0b8b0d789 This fixes copy with the remote_src option
It was broken in 6e37f1dcef0 when the remote_src was added. Need to
pass the absolute path to copy2 instead of a tuple.
2016-12-08 11:23:48 -05:00
Brian Coca 139201ad83 fixed remote_src support, now actually copies and does not move 2016-12-08 11:23:48 -05:00
Timothy Appnel f2e83fa452 Added the checksum_algo alias to the stats module. 2016-12-08 11:23:47 -05:00
Ales Nosek 4e787f17cf Make the syntax work with Python 2.4 2016-12-08 11:23:47 -05:00
Ales Nosek bd03dd67ff ini_file should only change what was specified and nothing more #5860
See also:
http://alesnosek.com/blog/2015/08/03/improving-ansibles-ini-file-module/
2016-12-08 11:23:47 -05:00
Brian Coca f7f8df1773 since find doesn't make changes, support check mode and gather data for other tasks in check mode 2016-12-08 11:23:44 -05:00
Toshio Kuratomi a179d06a91 Simplify logic to handle options set to empty string
Fixes #2125
2016-12-08 11:23:44 -05:00
Brian Coca 14455f4acc final form, use_regex now controls if patterns is glob or regex - fixed cases in which stat fails (dangling symlink) - now properly reports name of skipped paths 2016-12-08 11:23:43 -05:00
Brian Coca 3e5dc1fd74 changed so regexes and shell globs work transparently 2016-12-08 11:23:43 -05:00
Ryan Sydnor 8a1c035fac Add capability for stat module to use more hash algorithms
Specifically, the stat module now has a checksum_algorithm parameter.
This lets the module utilize one of the hash algorithms available on the host
to return the checksum of the file.

This change is backwards compatible. The checksum_algorithm defaults to
sha1 and still returns its result to the stat.checksum property.
2016-12-08 11:23:43 -05:00
Brian Coca 7c0dc323a2 corrected docs for stat's lnk_source fixes #12850 2016-12-08 11:23:42 -05:00
Brian Coca baeb6d8dc0 fixed bug in spec 2016-12-08 11:23:42 -05:00
Brian Coca a964754484 added regex support to find, also added 'singular' aliasess to patterns and paths 2016-12-08 11:23:42 -05:00
Brian Coca d6f474761d documented new remote_src option 2016-12-08 11:23:41 -05:00
varnav a05df49998 Fixed confusion in the docs
As 'path' is actually alias for 'dest', this could be confusing.
2016-12-08 11:23:37 -05:00
Toshio Kuratomi 58573187f8 Change the example of rsync_opts to use a list instead of a string
Fixes #9889
2016-12-08 11:23:37 -05:00
James Cammarata 4a4674ca24 Fix syntax error in synchronize docstring 2016-12-08 11:23:36 -05:00
skylerbunny dabf94ab1f Explanation of privilege escalation in notes
An attempt to make clear how privilege escalation works with respect to the src/source host and dest/destination host. One existing note was incorporated into three new ones, iterating each.
2016-12-08 11:23:36 -05:00
Jérémie Astori 6695cc5c21 Fix physical walk on acl module for Linux
`-h` is for BSD [1] while `-P`/`--physical` is for Linux [2].
This commit fixes that option now that acl module is (temporarily)
only supported for Linux.
I will re-add `-h` when fixing BSD support.

[1]: http://www.freebsd.org/cgi/man.cgi?format=html&query=setfacl(1)
[2]: http://linuxcommand.org/man_pages/setfacl1.html
2016-12-08 11:23:33 -05:00
Jérémie Astori 186cc7cb17 Make sure entry is not sent when acl state=query 2016-12-08 11:23:33 -05:00
Jérémie Astori 3568f1cd78 Make sure permission-less entries are accepted when state=absent
Also, remove that try condition as, at that stage, no permissions with
other than 2 or 3 fields are sent to the function.
2016-12-08 11:23:33 -05:00
Jérémie Astori a93445c798 Remove support for `d[efault]:` in entry permissions
It is not documented in [the Ansible doc page][1] nor
[the BSD setfacl man entry][2] (which means it might not be compatible
with BSD) so removing it does not break the API.

On the other hand, it does not conform with POSIX 1003.1e DRAFT
STANDARD 17 according to the [Linux setfacl man entry][3] so safer to
remove.

Finally, the most important reason: in non POSIX 1003.e mode, only ACL
entries without the permissions field are accepted, so having an
optional field here is very much error-prone.

[1]: http://docs.ansible.com/ansible/acl_module.html
[2]: http://www.freebsd.org/cgi/man.cgi?format=html&query=setfacl(1)
[3]: http://linuxcommand.org/man_pages/setfacl1.html
2016-12-08 11:23:33 -05:00
Jérémie Astori 1b34f1a7ac Fix wrong expectation regarding entry format in acl module 2016-12-08 11:23:32 -05:00
Jérémie Astori 6c298e20c0 Fix wrong processing of lines returned by setfacl in test mode 2016-12-08 11:23:32 -05:00
Jérémie Astori 08e8f732c5 Fix minor whitespace issues 2016-12-08 11:23:32 -05:00
Matthias Frey 2ed50d5e5b assemble: add file validation support. 2016-12-08 11:23:31 -05:00
Brian Coca a1992ad890 updated encoding comment and expanded authors field 2016-12-08 11:23:31 -05:00
Jérémie Astori 288a9d8500 Set version number in recursive option description 2016-12-08 11:23:30 -05:00
Jérémie Astori 17170992c3 Ensure Python 2.4 compatibility and Linux-restricted support
- Make build_entry compatible with Python 2.4
- Re-add missing warning/comment that was forgotten while refactoring
- Replace `all()` with a good ol' for-loop Python 2.4 compatibility
- Make a condition check more explicit (when `state` is `query`)
- Make sure this module can only be run with on a Linux distribution
- Add a note about Linux-only support in the documentation
- Set the version in which recursive support was added, 2.0
2016-12-08 11:23:30 -05:00
Marius Gedminas 9ab2e9c740 Fix obvious copy-paste error in module docs 2016-12-08 11:23:30 -05:00
Toshio Kuratomi a10b0e6fff Modify the default for synchronize's dest_port again 2016-12-08 11:23:30 -05:00
Toshio Kuratomi 052320b452 Update docs to reflect precedence for synchronize's dest_port param 2016-12-08 11:23:29 -05:00
Toshio Kuratomi 9ba5a438a8 Allow mode as a synchronize parameter (handled in action plugin) 2016-12-08 11:23:29 -05:00
Markus Juenemann 47065c2a43 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. 2016-12-08 11:23:29 -05:00
Jérémie Astori edf531efd7 Add recursive support for ACL module (fix #5053, fix #5550, fix #7276) 2016-12-08 11:23:28 -05:00
Toshio Kuratomi a01a800b65 Fi the local_rsync_path parameter used by the action plugin 2016-12-08 11:23:26 -05:00
James Cammarata ba9ba7d0f5 In copy, set the mode before running th validation
Because some programs that do validation (like visudo) may require
the permissions to be more restricted.

Fixes ansible/ansible#11385
2016-12-08 11:23:26 -05:00
Brian Coca 56354731ce fixed fragment docs 2016-12-08 11:23:26 -05:00
Mike Putnam 9623cd570c Add missing GPLv3 License header
Fixes #1643
2016-12-08 11:23:25 -05:00
Jeff Widman 70b3290a3b Move validate command into doc fragment and fix a few typos 2016-12-08 11:23:24 -05:00
Isaac Simmons 07ccd3c86b Handle ini file properties that contain interpolation errors in the initial values 2016-12-08 11:23:23 -05:00
Patrik Lundin 88881415e9 synchronize: add flag for verifying target host.
Add the possibility to verify the target host using a "verify_host"
flag. It is disabled by default to not change the module behaviour.
2016-12-08 11:23:22 -05:00
Brian Coca e4dd0d98d4 now captures any exceptions when trying to create directories 2016-12-08 11:23:21 -05:00
Brian Coca 60d160a2e9 Also document in example that unarchive download was added in 2.0 2016-12-08 11:23:20 -05:00
Mitchell Ludwig b664603a4d Improved stat documentation 2016-12-08 11:23:20 -05:00
Brian Coca f8f4a7dcdf added ignore hidden to assemble 2016-12-08 11:23:18 -05:00
Matthew Gilliard 17a40aa259 Handle race condition in directory creation.
If we try to make a directory, but someone else creates the directory
at the same time as us, we don't need to raise that error to the user.
They asked for the directory to exist, and now it does. This fixes
the race condition which was causing that error to be raised, and
closes #1648.
2016-12-08 11:23:16 -05:00
verm666 6acfa5fcee unarchive: fix @bcoca's remarks, issue #1575 2016-12-08 11:23:16 -05:00
verm666 b898cb656b unarchive: fix work with 0 bytes archives
This change is in response to issue #1575
2016-12-08 11:23:15 -05:00
Vladimir Martsul db646757c1 Add "force" description
Add "force" option description
2016-12-08 11:23:15 -05:00
gimoh fd69c5687b Do not insert extra newline if line already contains it
When using YAML multi-line strings, e.g.:

- lineinfile:
    dest: /tmp/foo
    line: >
      foo
      bar

the line already ends with a newline.  If an extra newline is appended unconditionally it will lead to inserting an extra newline on each run.
2016-12-08 11:23:13 -05:00
Toshio Kuratomi 870446dd6b Update version_added to 2.0 for the partial option 2016-12-08 11:23:12 -05:00
Juan Picca 81ea358b09 synchronize module: add partial option 2016-12-08 11:23:12 -05:00
Toshio Kuratomi 5f27a073ba Bump amount of file to download in a chunk to 64k. 2016-12-08 11:23:11 -05:00
Jonathan Mainguy dd0659c83d add download ability to unarchive module 2016-12-08 11:23:11 -05:00
Ritesh Khadgaray 9c3f9d23c8 Add the ability to grep for content 2016-12-08 11:23:09 -05:00
Greg DeKoenigsberg eb881d7d5d Proper author info for all remaining modules 2016-12-08 11:23:07 -05:00
Tristan Fisher 75ef963922 removes bool type from validate. 2016-12-08 11:23:03 -05:00
Tristan Fisher 0180be25c4 standardizes bools in argument_spec 2016-12-08 11:23:03 -05:00
jaypei fbc8d4ca4a use the right way to unescape line string Reference https://github.com/ansible/ansible/issues/10864 2016-12-08 11:23:03 -05:00
Brian Coca 322518d06c stat doc fix fixes #1371 2016-12-08 11:23:02 -05:00
Greg Taylor 79dd0466b5 Adding directory creation example to file module. 2016-12-08 11:23:00 -05:00
Brian Coca b4775234c9 minor docfix 2016-12-08 11:23:00 -05:00
Toshio Kuratomi 7e5a4afb6b Update module "imports" to new style
Fixes #1351
2016-12-08 11:23:00 -05:00
Toshio Kuratomi 20d7f929be Fix use of codecs.escape_decode() 2016-12-08 11:22:59 -05:00
Toshio Kuratomi 5204e94bda Slightly more future-proof version of the lineinfile fix 2016-12-08 11:22:59 -05:00
Toshio Kuratomi 1002fafedf Correct lineinfile documentation about double quoting... Hasn't been the case for years. 2016-12-08 11:22:59 -05:00
Jason Paige 329266975b update flat description
default behavior is to append the `hostname/path/to/file`, not prepend as currently stated by the flat arg docs
2016-12-08 11:22:59 -05:00
Brian Coca 0567404c03 generic fix for Exceptions that heppen when trying to set permissions on extracted files fixes ansible/ansible#10934 which is really a corner case 2016-12-08 11:22:58 -05:00
Ryan Hartkopf 118382ca70 synchronize: don't add ssh_args to ssh_opts when false or null 2016-12-08 11:22:56 -05:00