Commit graph

29 commits

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.
2016-09-01 04:19:15 -07:00
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.
2016-08-26 01:05:53 -07:00
Brian Coca
9dde201d87 unsafe writes! (#4314)
* unsafe writes!

* moved unsafe_write docs and args to file common

* added unsafe_writes option handling
2016-08-09 12:39:25 -04:00
Marcos Diez
9e197a5f78 The documentation of lineinfile now makes reference to blockinfile (#3639) 2016-05-24 14:49:09 +02:00
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
2016-02-18 05:35:17 -08:00
Jose Moreira
cb712f2ba8 Fixed module doc typos 2016-02-15 15:03:40 +00:00
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"
     }
2016-01-27 12:36:11 +01:00
Brian Coca
9b8470ae95 minor doc fixes 2015-07-24 17:57:13 -04:00
Jeff Widman
fd6518179b Move validate command into doc fragment and fix a few typos 2015-07-21 17:58:43 -07:00
Brian Coca
13116d8ac0 Merge pull request #839 from gimoh/patch-1
Do not insert extra newline if line already contains it
2015-06-30 00:09:42 -04:00
Greg DeKoenigsberg
2a5f0bde87 Proper author info for all remaining modules 2015-06-15 15:53:30 -04:00
jaypei
823adbbe36 use the right way to unescape line string
Reference https://github.com/ansible/ansible/issues/10864
2015-06-01 15:53:45 -07:00
Toshio Kuratomi
4b44aa4799 Fix use of codecs.escape_decode() 2015-05-17 09:28:14 -07:00
Toshio Kuratomi
142760658f Slightly more future-proof version of the lineinfile fix 2015-05-17 09:15:57 -07:00
Toshio Kuratomi
2eafbdd63a Merge branch 'fix-lineinfile' of https://github.com/jaypei/ansible-modules-core into jaypei-fix-lineinfile 2015-05-17 09:14:00 -07:00
Toshio Kuratomi
493144e06c Correct lineinfile documentation about double quoting... Hasn't been the case for years. 2015-05-15 14:13:27 -07:00
jaypei
fb34842a05 use the right way to unescape line string
Reference https://github.com/ansible/ansible/issues/10864
2015-04-29 19:59:55 +08:00
Toshio Kuratomi
559af8d88d Clarify the documented behaviour of insertbefore slightly. 2015-03-03 11:38:08 -08:00
Toshio Kuratomi
8ec43e5bbc Merge pull request #411 from p-tr0/devel
Fix behavior when insert* doesn't match anything
2015-03-03 11:32:18 -08:00
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.
2015-02-23 14:14:00 +00:00
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
2014-12-14 20:48:36 -05:00
Piotr Gosławski
a5b1a599e2 update docs for insertbefore/insertafter 2014-12-04 17:07:03 +01:00
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.
2014-11-30 12:32:08 +01:00
Eric
87dd3afc91 Fix lineinfile documentation typo 2014-11-29 22:41:24 -06: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
1c2995d71f Merge pull request #77 from major/suggest-selinux-enforcing
Updating SELinux example doc in lininefile module
2014-10-01 11:53:24 -04:00
Eric Hanchrow
cc0a38d268 Tweak docs to mention replace 2014-09-30 10:52:03 -07:00
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>
2014-09-30 07:12:23 -05:00
Michael DeHaan
c8e1a2077e file extensions! 2014-09-26 10:37:56 -04:00
Renamed from files/lineinfile (Browse further)