Improve config cleanup tasks (#262)

This commit is contained in:
Alessandro Fael Garcia 2020-06-12 23:42:14 +02:00 committed by GitHub
parent 7822449f25
commit 8ef117145f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 22 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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 }}"