From 6d2e8f77295e67eb0efec85829a6cf55973130cf Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Mon, 12 Jul 2021 01:44:52 -0400 Subject: [PATCH] [stable-2.11] file integration test - cleanup testing users and group (#75037) (cherry picked from commit 0467b1d477) Co-authored-by: Sam Doran --- .../targets/file/handlers/main.yml | 19 +++++++++++++++++++ test/integration/targets/file/tasks/main.yml | 6 ++++++ .../targets/file/tasks/state_link.yml | 1 + 3 files changed, 26 insertions(+) create mode 100644 test/integration/targets/file/handlers/main.yml diff --git a/test/integration/targets/file/handlers/main.yml b/test/integration/targets/file/handlers/main.yml new file mode 100644 index 00000000000..b5040f6e255 --- /dev/null +++ b/test/integration/targets/file/handlers/main.yml @@ -0,0 +1,19 @@ +- name: remove users + user: + name: "{{ item }}" + state: absent + remove: yes + loop: + - test1 + - test_uid + - nonexistent + - "{{ remote_unprivileged_user }}" + +- name: remove groups + group: + name: "{{ item }}" + state: absent + loop: + - test1 + - test_gid + - nonexistent1 diff --git a/test/integration/targets/file/tasks/main.yml b/test/integration/targets/file/tasks/main.yml index aefbdd63b18..565afa0260a 100644 --- a/test/integration/targets/file/tasks/main.yml +++ b/test/integration/targets/file/tasks/main.yml @@ -183,11 +183,13 @@ user: name: test1 uid: 1234 + notify: remove users - name: create group group: name: test1 gid: 1234 + notify: remove groups - name: change ownership and group file: path={{output_dir}}/baz.txt owner=1234 group=1234 @@ -604,6 +606,7 @@ - name: create owner user: name: nonexistent + notify: remove users # I don't use state=touch here intentionally to fail and catch warnings - name: owner exist in check_mode @@ -627,6 +630,7 @@ user: name: test_uid uid: 111111 + notify: remove users # I don't use state=touch here intentionally to fail and catch warnings - name: owner exists in check_mode, using uid @@ -650,6 +654,7 @@ - name: create group group: name: nonexistent1 + notify: remove groups # I don't use state=touch here intentionally to fail and catch warnings - name: group exists in check_mode @@ -673,6 +678,7 @@ group: name: test_gid gid: 111112 + notify: remove groups # I don't use state=touch here intentionally to fail and catch warnings - name: group exists in check_mode, using gid diff --git a/test/integration/targets/file/tasks/state_link.yml b/test/integration/targets/file/tasks/state_link.yml index 17534815381..d84bb3101e0 100644 --- a/test/integration/targets/file/tasks/state_link.yml +++ b/test/integration/targets/file/tasks/state_link.yml @@ -125,6 +125,7 @@ user: name: '{{ remote_unprivileged_user }}' register: user + notify: remove users - name: Create a local temporary directory tempfile: