From 0ee8a86a74ee12b519334b9dc495d2041ffb5ce1 Mon Sep 17 00:00:00 2001 From: Tas-sos Date: Fri, 4 Jun 2021 09:24:19 +0300 Subject: [PATCH] Added a way to remove/delete a module/theme. A way (first) delete the directory of an module/theme plus the configuration file of that module/theme. * [X] `ssp_mods_extra_disabled` : The list of modules/themes to be removed. --- roles/ssp-modules/defaults/main.yml | 28 ++++++++++++++++++++++ roles/ssp-modules/tasks/install-common.yml | 25 +++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/roles/ssp-modules/defaults/main.yml b/roles/ssp-modules/defaults/main.yml index 013be9a7..7de9db4d 100644 --- a/roles/ssp-modules/defaults/main.yml +++ b/roles/ssp-modules/defaults/main.yml @@ -8,6 +8,17 @@ ssp_modules_db: [] # Examples of use cases: ## Modules +#ssp_mods_extra_disabled: +# - name: module-a +# module_path: "{{ ssp_path }}/modules/module_directory_name" +# - name: module-x +# module_path: "{{ ssp_path }}/modules/module-x" +# dest_config_path: "{{ ssp_path }}/config/module_x.php" +# - name: module-x +# module_path: "{{ ssp_path }}/modules/module-x-v2.1.1" +# dest_config_path: "{{ ssp_path }}/config/module_x.php" +# +# #ssp_mods_extra_enabled: # - name: "module1" # path: "{{ ssp_path }}/modules/module1_directory" @@ -42,6 +53,23 @@ ssp_modules_db: [] # # or for example : # src_config_path: "{{ inventory_dir }}/files/templates/config/module_theme2_config.php.j2" # dest_config_path: "{{ ssp_path }}/config/module_theme2_config.php" +# - name: "theme3" +# fullname: "simplesamlphp-module-theme3 - 1st level of unziped directory" +# path: "{{ ssp_path }}/modules/theme3" +# zip_url: "https://github.com/example/simplesamlphp-module-theme3/releases/download/1.0.0/theme3.zip" +# version: "1.0.0" +# src_config_path: "{{ role_path }}/templates/config/module_theme3_config.php.j2" +# src_config_path: "{{ inventory_dir }}/files/templates/config/module_theme3_config.php.j2" +# dest_config_path: "{{ ssp_path }}/config/module_theme3_config.php" +# Same module/theme but in a different directory ( different version ) +# - name: "theme3" +# fullname: "simplesamlphp-module-theme3 - 1st level of unziped directory" +# path: "{{ ssp_path }}/modules/theme3-v2.1.1" # The different directory! +# zip_url: "https://github.com/example/simplesamlphp-module-theme3/releases/download/2.1.1/theme3.zip" +# version: "2.1.1" +# src_config_path: "{{ role_path }}/templates/config/module_theme3_config.php.j2" +# src_config_path: "{{ inventory_dir }}/files/templates/config/module_theme3_config.php.j2" +# dest_config_path: "{{ ssp_path }}/config/module_theme3_config.php" # # ## Extra dictionaries diff --git a/roles/ssp-modules/tasks/install-common.yml b/roles/ssp-modules/tasks/install-common.yml index df730b21..2e2e1452 100644 --- a/roles/ssp-modules/tasks/install-common.yml +++ b/roles/ssp-modules/tasks/install-common.yml @@ -21,6 +21,27 @@ when: item.repo_url is defined +- name: Remove/Disable SSP modules (1/2) + file: + path: "{{ item.module_path }}" + state: absent + become: yes + with_items: "{{ ssp_mods_extra_disabled }}" + tags: + - ssp_modules:config:remove + when: ssp_mods_extra_disabled is defined + +- name: Remove/Disable SSP modules (2/2) + file: + path: "{{ item.dest_config_path }}" + state: absent + become: yes + with_items: "{{ ssp_mods_extra_disabled }}" + when: (ssp_mods_extra_disabled is defined) and (item.dest_config_path is defined) + tags: + - ssp_modules:config:remove + + - name: Download & unarchive to /tmp/ ( zip only ) unarchive: src: "{{ item.zip_url }}" @@ -76,5 +97,5 @@ failed_when: "postgresql_result is failed and 'already exists' not in postgresql_result.msg" with_items: "{{ ssp_modules_db }}" when: "ssp_modules_db is defined" - tags: - - ssp_modules:install:db + +