From b089b03811f7c0a3e6b5a16507d6ad082704375c Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Mon, 27 Jul 2020 23:33:56 +0200 Subject: [PATCH] Add option to remove a specific list of files (#291) --- defaults/main/main.yml | 7 +++++-- molecule/common/playbooks/module_converge.yml | 4 +++- tasks/conf/cleanup-config.yml | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/defaults/main/main.yml b/defaults/main/main.yml index 12b1e70..08cd922 100644 --- a/defaults/main/main.yml +++ b/defaults/main/main.yml @@ -94,13 +94,16 @@ nginx_modules: # Remove previously existing NGINX configuration files. # You can specify a list of paths you wish to remove. -# Alternatively you can also choose whether to recurse through the paths specified. +# You can also choose whether to recurse through the paths specified. +# Alternatively you can specify the list of files you wish to remove. # Default is false. nginx_cleanup_config: false -nginx_cleanup_config_path: +nginx_cleanup_config_paths: - directory: - /etc/nginx/conf.d recurse: false +# nginx_cleanup_config_files: +# - /etc/nginx/conf.d/default.conf # Set selinux enforcing for nginx (Centos/Redhat only) - you may need to open ports on your own nginx_selinux: false diff --git a/molecule/common/playbooks/module_converge.yml b/molecule/common/playbooks/module_converge.yml index 2995413..befc6e4 100644 --- a/molecule/common/playbooks/module_converge.yml +++ b/molecule/common/playbooks/module_converge.yml @@ -14,10 +14,12 @@ - 443 nginx_cleanup_config: true - nginx_cleanup_config_path: + nginx_cleanup_config_paths: - directory: - /etc/nginx/conf.d recurse: false + nginx_cleanup_config_files: + - /etc/nginx/conf.d/default.conf nginx_modules: njs: true diff --git a/tasks/conf/cleanup-config.yml b/tasks/conf/cleanup-config.yml index f891983..ef9ee9e 100644 --- a/tasks/conf/cleanup-config.yml +++ b/tasks/conf/cleanup-config.yml @@ -4,11 +4,14 @@ paths: "{{ item.directory }}" patterns: "*.conf" recurse: "{{ item.recurse | default(false) }}" - loop: "{{ nginx_cleanup_config_path }}" + loop: "{{ nginx_cleanup_config_paths }}" + when: nginx_cleanup_config_paths is defined register: nginx_config_files - name: "(Setup: All OSs) Remove NGINX Configuration Files" file: path: "{{ item }}" state: absent - loop: "{{ nginx_config_files.results | map(attribute='files') | sum(start=[]) | map(attribute='path') | list }}" + loop: >- + {{ nginx_config_files.results | default('') | map(attribute='files') | sum(start=[]) | map(attribute='path') | list + + nginx_cleanup_config_files | default('') }}