Add killing all user processing prior to removing the user
PROD-33024
Change-Id: I19c9e3e490b97da57404edda83ce53f6608841a2
diff --git a/README.rst b/README.rst
index a0fb69d..a994498 100644
--- a/README.rst
+++ b/README.rst
@@ -76,7 +76,7 @@
home: '/home/elizabeth'
password: "$6$nUI7QEz3$dFYjzQqK5cJ6HQ38KqG4gTWA9eJu3aKx6TRVDFh6BVJxJgFWg2akfAA7f1fCxcSUeOJ2arCO6EEI6XXnHXxG10"
-Remove users data completely:
+Remove users data completely and terminate all user's processes:
.. code-block:: yaml
diff --git a/linux/system/user.sls b/linux/system/user.sls
index b8fa13c..6f4c2a3 100644
--- a/linux/system/user.sls
+++ b/linux/system/user.sls
@@ -124,6 +124,17 @@
{%- endif %}
{%- else %}
+{%- if user.get('force_delete', 'False') %}
+
+system_user_{{ name }}_terminate_processes:
+ cmd.run:
+ - name: pkill -U {{ name }}
+ - onlyif: id -u {{ name }} && ps -u {{ name }}
+ - require_in:
+ - user: system_user_{{ name }}
+
+{%- endif %}
+
system_user_{{ name }}:
user.absent:
- name: {{ name }}
@@ -139,4 +150,3 @@
{%- endif %}
{%- endfor %}
{%- endif %}
-
\ No newline at end of file