From 8a907de79635d22692283594d57b857d293e2ee4 Mon Sep 17 00:00:00 2001
From: Juan Ferrer Toribio <juan@verdnatura.es>
Date: Thu, 6 Feb 2025 08:05:53 +0100
Subject: [PATCH] refs #7593 Clean task reorganized

---
 playbooks/clean.yml | 64 +++++++++++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 28 deletions(-)

diff --git a/playbooks/clean.yml b/playbooks/clean.yml
index 763e5a0..68958a6 100644
--- a/playbooks/clean.yml
+++ b/playbooks/clean.yml
@@ -2,38 +2,46 @@
   hosts: all
   gather_facts: no
   tasks:
-  - name: Delete awx-user
-    user:
-      name: awx-user
-      state: absent
-      remove: yes
-    tags: awx
-  - name: Delete awx-user sudoers file
-    file:
-      path: /etc/sudoers.d/awx-user
-      state: absent
-    tags: awx
+
+  - name: Delete old awx-user and it's configuration
+    block:
+    - name: Delete awx-user
+      tags: awx
+      user:
+        name: awx-user
+        state: absent
+        remove: yes
+    - name: Delete awx-user sudoers file
+      tags: awx
+      file:
+        path: /etc/sudoers.d/awx-user
+        state: absent
+
   - name: Delete old MOTD configuration
+    tags: motd
     file:
       path: /etc/profile.d/mymotd.sh
       state: absent
-    tags: motd
-  - name: Delete old Ansible bashrc configuration
-    blockinfile:
-      path: /root/.bashrc
-      marker_begin: 'BEGIN ANSIBLE MANAGED BLOCK'
-      marker_end: 'END ANSIBLE MANAGED BLOCK'
-      marker: "# {mark}"
-      state: absent
-    tags: bashrc
-  - name: Delete old custom bashrc configuration
-    replace:
-      path: /root/.bashrc
-      regexp: '{{ start_delimiter }}\\s\\S*?{{ end_delimiter }}'
-      replace: ''
-    vars:
-      start_delimiter: '### 4Loo'
-      end_delimiter: 'esac'
+
+  - name: Delete old profile configuration
+    tags: profile
+    block:
+    - name: Delete old Ansible bashrc configuration
+      blockinfile:
+        path: /root/.bashrc
+        marker_begin: 'BEGIN ANSIBLE MANAGED BLOCK'
+        marker_end: 'END ANSIBLE MANAGED BLOCK'
+        marker: "# {mark}"
+        state: absent
+    - name: Delete old custom bashrc configuration
+      replace:
+        path: /root/.bashrc
+        regexp: '{{ start_delimiter }}\\s\\S*?{{ end_delimiter }}'
+        replace: ''
+      vars:
+        start_delimiter: '### 4Loo'
+        end_delimiter: 'esac'
+
   - name: Delete old vn-host package
     tags: vn-host
     block: