From 010e542a13516eed9bb6b5e997ea255104257a80 Mon Sep 17 00:00:00 2001 From: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> Date: Wed, 26 Jul 2023 18:19:04 -0400 Subject: [PATCH] Fix blockinfile code comment (#81351) --- lib/ansible/modules/blockinfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/blockinfile.py b/lib/ansible/modules/blockinfile.py index b48b1820602..a44285197a5 100644 --- a/lib/ansible/modules/blockinfile.py +++ b/lib/ansible/modules/blockinfile.py @@ -359,8 +359,8 @@ def main(): lines[n0 - 1] += b(os.linesep) # Before the block: check if we need to prepend a blank line - # If yes, we need to add the blank line if we are at the beginning of the file - # or if the previous line is not a blank line + # If yes, we need to add the blank line if we are not at the beginning of the file + # and the previous line is not a blank line # In both cases, we need to shift by one on the right the inserting position of the block if params['prepend_newline'] and present: if n0 != 0 and lines[n0 - 1] != b(os.linesep): @@ -371,8 +371,8 @@ def main(): lines[n0:n0] = blocklines # After the block: check if we need to append a blank line - # If yes, we need to add the blank line if we are at the end of the file - # or if the line right after is not a blank line + # If yes, we need to add the blank line if we are not at the end of the file + # and the line right after is not a blank line if params['append_newline'] and present: line_after_block = n0 + len(blocklines) if line_after_block < len(lines) and lines[line_after_block] != b(os.linesep):