From 98022a7e61590bbd416b3e4b45b5df1b6eece654 Mon Sep 17 00:00:00 2001
From: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date: Wed, 6 Oct 2021 14:55:04 +0200
Subject: [PATCH] clean: also the vitrualenv (#57642)

---
 clean.yml                  | 83 +++-----------------------------------
 roles/clean/tasks/main.yml | 77 +++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 78 deletions(-)
 create mode 100644 roles/clean/tasks/main.yml

diff --git a/clean.yml b/clean.yml
index 9dd6981..1eeda3b 100644
--- a/clean.yml
+++ b/clean.yml
@@ -1,79 +1,6 @@
 ---
-- hosts: local
-  tasks:
-    - name: delete python venvs
-      file:
-        path: "{{venv_py3}}"
-        state: absent
-
-    - name: delete app /var/lib directory
-      file:
-        path: "/var/lib/{{item.value.project_name}}"
-        state: absent
-      with_dict: "{{apps}}"
-      become: yes
-
-    - name: delete server /var/log directory
-      file:
-        path: "/var/log/{{item.value.project_name}}-server"
-        state: absent
-      with_dict: "{{apps}}"
-      become: yes
-
-    - name: delete agent /var/log directory
-      file:
-        path: "/var/log/hobo-agent"
-        state: absent
-      become: yes
-
-    - name: delete supervisor server conf 
-      file:
-        path: "/etc/supervisor/conf.d/{{item.value.project_name}}-server.conf"
-        state: absent
-      with_dict: "{{apps}}"
-      become: yes
-      
-    - name: delete supervisor agent conf 
-      file:
-        path: "/etc/supervisor/conf.d/hobo-agent.conf"
-        state: absent
-      become: yes
-
-    - name: reload supervisor
-      shell: /etc/init.d/supervisor reload
-      become: yes
-
-    - name: delete nginx app server conf link
-      file:
-        path: "/etc/nginx/sites-enabled/{{item.value.project_name}}"
-        state: absent
-      with_dict: "{{apps}}"
-      become: yes
-
-    - name: delete nginx app server conf 
-      file:
-        path: "/etc/nginx/sites-available/{{item.value.project_name}}"
-        state: absent
-      with_dict: "{{apps}}"
-      become: yes
-
-    - name: reload nginx
-      shell: /etc/init.d/nginx reload
-      become: yes
-
-    - name: delete /etc app directory
-      file:
-        path: "/etc/{{item.value.project_name}}"
-        state: absent
-      with_dict: "{{apps}}"
-      become: yes
-      
-    - name: delete db
-      postgresql_db:
-        name: "{{item.value.db_name}}"
-        state: absent
-        port: "{{postgresql_port}}"
-      with_dict: "{{apps}}"
-      become: yes
-      become_user: postgres
-
+- name: delete publik installation
+  hosts: local
+  roles:
+    - facts
+    - clean
diff --git a/roles/clean/tasks/main.yml b/roles/clean/tasks/main.yml
new file mode 100644
index 0000000..bd57750
--- /dev/null
+++ b/roles/clean/tasks/main.yml
@@ -0,0 +1,77 @@
+
+- name: delete python venvs
+  file:
+    path: "{{venv_py3}}"
+    state: absent
+
+- name: delete app /var/lib directory
+  file:
+    path: "/var/lib/{{item.value.project_name}}"
+    state: absent
+  with_dict: "{{apps}}"
+  become: yes
+
+- name: delete server /var/log directory
+  file:
+    path: "/var/log/{{item.value.project_name}}-server"
+    state: absent
+  with_dict: "{{apps}}"
+  become: yes
+
+- name: delete agent /var/log directory
+  file:
+    path: "/var/log/hobo-agent"
+    state: absent
+  become: yes
+
+- name: delete supervisor server conf 
+  file:
+    path: "/etc/supervisor/conf.d/{{item.value.project_name}}-server.conf"
+    state: absent
+  with_dict: "{{apps}}"
+  become: yes
+  
+- name: delete supervisor agent conf 
+  file:
+    path: "/etc/supervisor/conf.d/hobo-agent.conf"
+    state: absent
+  become: yes
+
+- name: reload supervisor
+  shell: /etc/init.d/supervisor reload
+  become: yes
+
+- name: delete nginx app server conf link
+  file:
+    path: "/etc/nginx/sites-enabled/{{item.value.project_name}}"
+    state: absent
+  with_dict: "{{apps}}"
+  become: yes
+
+- name: delete nginx app server conf 
+  file:
+    path: "/etc/nginx/sites-available/{{item.value.project_name}}"
+    state: absent
+  with_dict: "{{apps}}"
+  become: yes
+
+- name: reload nginx
+  shell: /etc/init.d/nginx reload
+  become: yes
+
+- name: delete /etc app directory
+  file:
+    path: "/etc/{{item.value.project_name}}"
+    state: absent
+  with_dict: "{{apps}}"
+  become: yes
+  
+- name: delete db
+  postgresql_db:
+    name: "{{item.value.db_name}}"
+    state: absent
+    port: "{{postgresql_port}}"
+  with_dict: "{{apps}}"
+  become: yes
+  become_user: postgres
+
-- 
2.30.2

