Skip to content

Commit b089b03

Browse files
authored
Add option to remove a specific list of files (#291)
1 parent 36b42e5 commit b089b03

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

defaults/main/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ nginx_modules:
9494

9595
# Remove previously existing NGINX configuration files.
9696
# You can specify a list of paths you wish to remove.
97-
# Alternatively you can also choose whether to recurse through the paths specified.
97+
# You can also choose whether to recurse through the paths specified.
98+
# Alternatively you can specify the list of files you wish to remove.
9899
# Default is false.
99100
nginx_cleanup_config: false
100-
nginx_cleanup_config_path:
101+
nginx_cleanup_config_paths:
101102
- directory:
102103
- /etc/nginx/conf.d
103104
recurse: false
105+
# nginx_cleanup_config_files:
106+
# - /etc/nginx/conf.d/default.conf
104107

105108
# Set selinux enforcing for nginx (Centos/Redhat only) - you may need to open ports on your own
106109
nginx_selinux: false

molecule/common/playbooks/module_converge.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
- 443
1515

1616
nginx_cleanup_config: true
17-
nginx_cleanup_config_path:
17+
nginx_cleanup_config_paths:
1818
- directory:
1919
- /etc/nginx/conf.d
2020
recurse: false
21+
nginx_cleanup_config_files:
22+
- /etc/nginx/conf.d/default.conf
2123

2224
nginx_modules:
2325
njs: true

tasks/conf/cleanup-config.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
paths: "{{ item.directory }}"
55
patterns: "*.conf"
66
recurse: "{{ item.recurse | default(false) }}"
7-
loop: "{{ nginx_cleanup_config_path }}"
7+
loop: "{{ nginx_cleanup_config_paths }}"
8+
when: nginx_cleanup_config_paths is defined
89
register: nginx_config_files
910

1011
- name: "(Setup: All OSs) Remove NGINX Configuration Files"
1112
file:
1213
path: "{{ item }}"
1314
state: absent
14-
loop: "{{ nginx_config_files.results | map(attribute='files') | sum(start=[]) | map(attribute='path') | list }}"
15+
loop: >-
16+
{{ nginx_config_files.results | default('') | map(attribute='files') | sum(start=[]) | map(attribute='path') | list
17+
+ nginx_cleanup_config_files | default('') }}

0 commit comments

Comments
 (0)