From 91f7d54a49f21a602d98bef3a239b5dcc3da0da4 Mon Sep 17 00:00:00 2001 From: Colin Hoglund Date: Wed, 24 May 2017 13:19:28 -0400 Subject: [PATCH] adding remove and force options for users_deleted --- README.md | 9 +++++++++ tasks/main.yml | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03ca60f..d286746 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,12 @@ in the system, and these will be removed on the next ansible run. The format is the same as for users to add, but the only required field is `username`. However, it is recommended that you also keep the `uid` field for reference so that numeric user ids are not accidentally reused. + +You can optionally choose to remove the user's home directory and mail spool with +the `remove` parameter, and force removal of files with the `force` parameter. + + users_deleted: + - username: bar + uid: 1002 + remove: yes + force: yes diff --git a/tasks/main.yml b/tasks/main.yml index 7724940..738105d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,11 @@ with_items: "{{users}}" - name: Deleted user removal - user: name="{{item.username}}" state=absent + user: + name: "{{item.username}}" + state: absent + remove: "{{item.remove | default(omit)}}" + force: "{{item.force | default(omit)}}" with_items: "{{users_deleted}}" tags: ['users','configuration']