Skip to content

Commit 8ef1171

Browse files
authored
Improve config cleanup tasks (#262)
1 parent 7822449 commit 8ef1171

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

defaults/main/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ nginx_modules:
8686
xslt: false
8787

8888
# Remove previously existing NGINX configuration files.
89-
# Use a list of paths you wish to remove.
89+
# You can specify a list of paths you wish to remove.
90+
# Alternatively you can also choose whether to recurse through the paths specified.
9091
# Default is false.
9192
nginx_cleanup_config: false
9293
nginx_cleanup_config_path:
93-
- /etc/nginx/conf.d
94+
- directory:
95+
- /etc/nginx/conf.d
96+
recurse: false

molecule/common/playbook_default_verifier.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

molecule/common/playbook_module.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
vars:
77
nginx_debug_output: true
88

9+
nginx_cleanup_config: true
10+
nginx_cleanup_config_path:
11+
- directory:
12+
- /etc/nginx/conf.d
13+
recurse: false
14+
915
nginx_modules:
1016
njs: true
1117
perl: true

molecule/common/test_module/test_default.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,3 @@ def test_hosts_file(host):
2222
assert ngx.exists
2323
assert ngx.user == 'root'
2424
assert ngx.group == 'root'
25-
26-
27-
def test_endpoint(host):
28-
command = """curl -I http://localhost/"""
29-
cmd = host.run(command)
30-
assert '200 OK' in cmd.stdout

tasks/conf/cleanup-config.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
---
2-
- name: "(Setup: All OSs) Remove NGINX configuration files"
2+
- name: "(Setup: All OSs) Find NGINX Configuration Files"
3+
find:
4+
paths: "{{ item.directory }}"
5+
patterns: "*.conf"
6+
recurse: "{{ item.recurse | default(false) }}"
7+
loop: "{{ nginx_cleanup_config_path }}"
8+
register: nginx_config_files
9+
10+
- name: "(Setup: All OSs) Remove NGINX Configuration Files"
311
file:
412
path: "{{ item }}"
513
state: absent
6-
with_items:
7-
- "{{ nginx_cleanup_config_path }}"
8-
notify: "(Handler: All OSs) Reload NGINX"
14+
loop: "{{ nginx_config_files.results | map(attribute='files') | sum(start=[]) | map(attribute='path') | list }}"

0 commit comments

Comments
 (0)