diff --git a/defaults/main/main.yml b/defaults/main/main.yml index bcb3dec..3c5a404 100644 --- a/defaults/main/main.yml +++ b/defaults/main/main.yml @@ -86,8 +86,11 @@ nginx_modules: xslt: false # Remove previously existing NGINX configuration files. -# Use 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. # Default is false. nginx_cleanup_config: false nginx_cleanup_config_path: - - /etc/nginx/conf.d + - directory: + - /etc/nginx/conf.d + recurse: false diff --git a/molecule/common/playbook_default_verifier.yml b/molecule/common/playbook_default_verifier.yml deleted file mode 100644 index f9c8b8a..0000000 --- a/molecule/common/playbook_default_verifier.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Verify - hosts: all - tasks: - - name: "Test NGINX is installed" - assert: - - name: "Test NGINX service is running and enabled" - assert: - - name: "Test NGINX is listening" - assert: diff --git a/molecule/common/playbook_module.yml b/molecule/common/playbook_module.yml index 3f42b42..b7b1f3b 100644 --- a/molecule/common/playbook_module.yml +++ b/molecule/common/playbook_module.yml @@ -6,6 +6,12 @@ vars: nginx_debug_output: true + nginx_cleanup_config: true + nginx_cleanup_config_path: + - directory: + - /etc/nginx/conf.d + recurse: false + nginx_modules: njs: true perl: true diff --git a/molecule/common/test_module/test_default.py b/molecule/common/test_module/test_default.py index 8d12025..aed00c0 100644 --- a/molecule/common/test_module/test_default.py +++ b/molecule/common/test_module/test_default.py @@ -22,9 +22,3 @@ def test_hosts_file(host): assert ngx.exists assert ngx.user == 'root' assert ngx.group == 'root' - - -def test_endpoint(host): - command = """curl -I http://localhost/""" - cmd = host.run(command) - assert '200 OK' in cmd.stdout diff --git a/tasks/conf/cleanup-config.yml b/tasks/conf/cleanup-config.yml index 9eb405c..f891983 100644 --- a/tasks/conf/cleanup-config.yml +++ b/tasks/conf/cleanup-config.yml @@ -1,8 +1,14 @@ --- -- name: "(Setup: All OSs) Remove NGINX configuration files" +- name: "(Setup: All OSs) Find NGINX Configuration Files" + find: + paths: "{{ item.directory }}" + patterns: "*.conf" + recurse: "{{ item.recurse | default(false) }}" + loop: "{{ nginx_cleanup_config_path }}" + register: nginx_config_files + +- name: "(Setup: All OSs) Remove NGINX Configuration Files" file: path: "{{ item }}" state: absent - with_items: - - "{{ nginx_cleanup_config_path }}" - notify: "(Handler: All OSs) Reload NGINX" + loop: "{{ nginx_config_files.results | map(attribute='files') | sum(start=[]) | map(attribute='path') | list }}"