Add option to remove a specific list of files (#291)

This commit is contained in:
Alessandro Fael Garcia 2020-07-27 23:33:56 +02:00 committed by GitHub
parent 36b42e563a
commit b089b03811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -94,13 +94,16 @@ nginx_modules:
# Remove previously existing NGINX configuration files. # Remove previously existing NGINX configuration files.
# You can specify a list of paths you wish to remove. # 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. # Default is false.
nginx_cleanup_config: false nginx_cleanup_config: false
nginx_cleanup_config_path: nginx_cleanup_config_paths:
- directory: - directory:
- /etc/nginx/conf.d - /etc/nginx/conf.d
recurse: false 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 # Set selinux enforcing for nginx (Centos/Redhat only) - you may need to open ports on your own
nginx_selinux: false nginx_selinux: false

View File

@ -14,10 +14,12 @@
- 443 - 443
nginx_cleanup_config: true nginx_cleanup_config: true
nginx_cleanup_config_path: nginx_cleanup_config_paths:
- directory: - directory:
- /etc/nginx/conf.d - /etc/nginx/conf.d
recurse: false recurse: false
nginx_cleanup_config_files:
- /etc/nginx/conf.d/default.conf
nginx_modules: nginx_modules:
njs: true njs: true

View File

@ -4,11 +4,14 @@
paths: "{{ item.directory }}" paths: "{{ item.directory }}"
patterns: "*.conf" patterns: "*.conf"
recurse: "{{ item.recurse | default(false) }}" 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 register: nginx_config_files
- name: "(Setup: All OSs) Remove NGINX Configuration Files" - name: "(Setup: All OSs) Remove NGINX Configuration Files"
file: file:
path: "{{ item }}" path: "{{ item }}"
state: absent 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('') }}