Commit Graph

29 Commits (41f57373345d8424845752401f8da7b52c378683)

Author SHA1 Message Date
Toshio Kuratomi 7e79c59d38 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.
8 years ago
Toshio Kuratomi 4912ec30a7 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.
8 years ago
Brian Coca 9dde201d87 unsafe writes! (#4314)
* unsafe writes!

* moved unsafe_write docs and args to file common

* added unsafe_writes option handling
8 years ago
Marcos Diez 9e197a5f78 The documentation of lineinfile now makes reference to blockinfile (#3639) 8 years ago
Brian Coca cefdb9a494 Merge pull request #2896 from towolf/add_diff_to_lineinfile
Add diff to lineinfile.py for both file contents and file attributes
9 years ago
Jose Moreira cb712f2ba8 Fixed module doc typos 9 years ago
Tobias Wolf 99ba594f0a 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"
     }
9 years ago
Brian Coca 9b8470ae95 minor doc fixes 9 years ago
Jeff Widman fd6518179b Move validate command into doc fragment and fix a few typos 9 years ago
Brian Coca 13116d8ac0 Merge pull request #839 from gimoh/patch-1
Do not insert extra newline if line already contains it
9 years ago
Greg DeKoenigsberg 2a5f0bde87 Proper author info for all remaining modules 9 years ago
jaypei 823adbbe36 use the right way to unescape line string
Reference https://github.com/ansible/ansible/issues/10864
9 years ago
Toshio Kuratomi 4b44aa4799 Fix use of codecs.escape_decode() 9 years ago
Toshio Kuratomi 142760658f Slightly more future-proof version of the lineinfile fix 9 years ago
Toshio Kuratomi 2eafbdd63a Merge branch 'fix-lineinfile' of https://github.com/jaypei/ansible-modules-core into jaypei-fix-lineinfile 9 years ago
Toshio Kuratomi 493144e06c Correct lineinfile documentation about double quoting... Hasn't been the case for years. 9 years ago
jaypei fb34842a05 use the right way to unescape line string
Reference https://github.com/ansible/ansible/issues/10864
10 years ago
Toshio Kuratomi 559af8d88d Clarify the documented behaviour of insertbefore slightly. 10 years ago
Toshio Kuratomi 8ec43e5bbc Merge pull request #411 from p-tr0/devel
Fix behavior when insert* doesn't match anything
10 years ago
gimoh d9f8fa56d8 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.
10 years ago
Jeff Bradberry 28375aae7f Fix breakage in lineinfile check mode when target file does not exist.
Similarly to https://github.com/ansible/ansible/issues/6182, checking of the file attributes should be avoided in check mode when the file didn't originally exist.

Also, avoid creating parent directories in check mode.

Fixes https://github.com/ansible/ansible/issues/9546
10 years ago
Piotr Gosławski a5b1a599e2 update docs for insertbefore/insertafter 10 years ago
Piotr Gosławski 3c8b4bd4b9 Fix behavior when insert* doesn't match anything
If insertbefore/insertafter didn't match anything, lineinfile module was doing nothing, instead of adding the line at end of fille as it's supposed to.
10 years ago
Eric 87dd3afc91 Fix lineinfile documentation typo 10 years ago
James Cammarata cb69744bce Adding file doc fragment to those modules in files/ missing it 10 years ago
Michael DeHaan 1c2995d71f Merge pull request #77 from major/suggest-selinux-enforcing
Updating SELinux example doc in lininefile module
10 years ago
Eric Hanchrow cc0a38d268 Tweak docs to mention `replace` 10 years ago
Major Hayden 6d697780f9 Updating SELinux example doc in lininefile module
Encouraging users to use this Ansible module to enable SELinux seems
like a better idea. It also warms Dan Walsh's heart.

Signed-off-by: Major Hayden <major@mhtx.net>
10 years ago
Michael DeHaan c8e1a2077e file extensions! 10 years ago