diff --git a/changelogs/fragments/blockinfile-unused-code.yml b/changelogs/fragments/blockinfile-unused-code.yml new file mode 100644 index 00000000000..37c0ee65038 --- /dev/null +++ b/changelogs/fragments/blockinfile-unused-code.yml @@ -0,0 +1,2 @@ +minor_changes: + - blockinfile - Remove unused code for Ansible 1.x. diff --git a/lib/ansible/modules/blockinfile.py b/lib/ansible/modules/blockinfile.py index fde44b5d600..668c67a3c40 100644 --- a/lib/ansible/modules/blockinfile.py +++ b/lib/ansible/modules/blockinfile.py @@ -265,9 +265,6 @@ def main(): marker0 = re.sub(b(r'{mark}'), b(params['marker_begin']), marker) + b(os.linesep) marker1 = re.sub(b(r'{mark}'), b(params['marker_end']), marker) + b(os.linesep) if present and block: - # Escape sequences like '\n' need to be handled in Ansible 1.x - if module.ansible_version.startswith('1.'): - block = re.sub('', block, '') if not block.endswith(b(os.linesep)): block += b(os.linesep) blocklines = [marker0] + block.splitlines(True) + [marker1]