Merge branch 'jaypei-fix-lineinfile' into devel
This commit is contained in:
commit
94246003d5
1 changed files with 5 additions and 16 deletions
|
@ -19,9 +19,10 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pipes
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import pipes
|
||||||
|
import codecs
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
|
@ -369,25 +370,13 @@ def main():
|
||||||
|
|
||||||
line = params['line']
|
line = params['line']
|
||||||
|
|
||||||
# The safe_eval call will remove some quoting, but not others,
|
|
||||||
# so we need to know if we should specifically unquote it.
|
|
||||||
should_unquote = not is_quoted(line)
|
|
||||||
|
|
||||||
# always add one layer of quotes
|
|
||||||
line = "'%s'" % line
|
|
||||||
|
|
||||||
# Replace escape sequences like '\n' while being sure
|
# Replace escape sequences like '\n' while being sure
|
||||||
# not to replace octal escape sequences (\ooo) since they
|
# not to replace octal escape sequences (\ooo) since they
|
||||||
# match the backref syntax.
|
# match the backref syntax.
|
||||||
if backrefs:
|
if backrefs:
|
||||||
line = re.sub(r'(\\[0-9]{1,3})', r'\\\1', line)
|
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
|
line = codecs.escape_decode(line)
|
||||||
# removing the layer we added above
|
|
||||||
line = unquote(line)
|
|
||||||
if should_unquote:
|
|
||||||
line = unquote(line)
|
|
||||||
|
|
||||||
present(module, dest, params['regexp'], line,
|
present(module, dest, params['regexp'], line,
|
||||||
ins_aft, ins_bef, create, backup, backrefs)
|
ins_aft, ins_bef, create, backup, backrefs)
|
||||||
|
@ -400,5 +389,5 @@ def main():
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.splitter import *
|
from ansible.module_utils.splitter import *
|
||||||
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue