From 230f956e255ea1a98c57e947b341f89bf0b93abc Mon Sep 17 00:00:00 2001 From: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:07:53 -0400 Subject: [PATCH] Add lineinfile integration test for removing a line that has already been removed (#81762) ci_complete ci_coverage --- .../targets/lineinfile/tasks/main.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/integration/targets/lineinfile/tasks/main.yml b/test/integration/targets/lineinfile/tasks/main.yml index 3d4678c2b25..b7c7f626bec 100644 --- a/test/integration/targets/lineinfile/tasks/main.yml +++ b/test/integration/targets/lineinfile/tasks/main.yml @@ -258,6 +258,27 @@ that: - "result.stat.checksum == 'd4eeb07bdebab2d1cdb3ec4a3635afa2618ad4ea'" +- name: try to remove the middle line again + lineinfile: + dest: "{{ remote_tmp_dir }}/test.txt" + state: absent + regexp: "^This is line 3$" + register: result + +- name: assert no change was made + assert: + that: result is not changed + +- name: use stat to verify no change was made + stat: + path: "{{ remote_tmp_dir }}/test.txt" + register: result + +- name: assert test checksum matches after the middle line was removed + assert: + that: + - "result.stat.checksum == 'd4eeb07bdebab2d1cdb3ec4a3635afa2618ad4ea'" + - name: run a validation script that succeeds lineinfile: dest: "{{ remote_tmp_dir }}/test.txt"