summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2021-07-12 01:44:52 -0400
committerGitHub <noreply@github.com>2021-07-12 00:44:52 -0500
commit6d2e8f77295e67eb0efec85829a6cf55973130cf (patch)
tree596d1ea8d0a145df1f8b42a5777de352f87acd63
parentb3115e3c16f0bddc90414b8a224d4d06605e4298 (diff)
downloadansible-6d2e8f77295e67eb0efec85829a6cf55973130cf.tar.gz
[stable-2.11] file integration test - cleanup testing users and group (#75037)
(cherry picked from commit 0467b1d477) Co-authored-by: Sam Doran <sdoran@redhat.com>
-rw-r--r--test/integration/targets/file/handlers/main.yml19
-rw-r--r--test/integration/targets/file/tasks/main.yml6
-rw-r--r--test/integration/targets/file/tasks/state_link.yml1
3 files changed, 26 insertions, 0 deletions
diff --git a/test/integration/targets/file/handlers/main.yml b/test/integration/targets/file/handlers/main.yml
new file mode 100644
index 0000000000..b5040f6e25
--- /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 aefbdd63b1..565afa0260 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 1753481538..d84bb3101e 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: