From 5204e94bdadd9b0f0d7c62a37e87aebf061cfe39 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sun, 17 May 2015 09:15:57 -0700 Subject: [PATCH] Slightly more future-proof version of the lineinfile fix --- lib/ansible/modules/files/lineinfile.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/files/lineinfile.py b/lib/ansible/modules/files/lineinfile.py index 282feab70cf..d22b9781f1f 100644 --- a/lib/ansible/modules/files/lineinfile.py +++ b/lib/ansible/modules/files/lineinfile.py @@ -19,9 +19,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -import pipes import re import os +import pipes +import codecs import tempfile DOCUMENTATION = """ @@ -383,11 +384,7 @@ def main(): line = re.sub(r'(\\[0-9]{1,3})', r'\\\1', line) line = module.safe_eval(line) - # Now remove quotes around the string, if needed after - # removing the layer we added above - line = unquote(line) - if should_unquote: - line = unquote(line) + line = codecs.escape_decode(line) present(module, dest, params['regexp'], line, ins_aft, ins_bef, create, backup, backrefs) @@ -400,5 +397,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.splitter import * - -main() +if __name__ == '__main__': + main()