From 3593619931599521ca954d691721e06d83df4837 Mon Sep 17 00:00:00 2001 From: Colin Hoglund Date: Wed, 12 Apr 2017 17:26:39 -0400 Subject: [PATCH 1/2] use find module when cleaning vhosts --- meta/main.yml | 2 +- tasks/vhosts.yml | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index d3e6b95f..bf03fa9e 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -5,7 +5,7 @@ galaxy_info: author: geerlingguy w/ modifications by SinglePlatform description: Nginx installation for Linux/UNIX. license: "license (BSD, MIT)" - min_ansible_version: 1.9 + min_ansible_version: 2.0 platforms: - name: EL versions: diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 88019e02..195b7b04 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -5,20 +5,19 @@ dest: "{{nginx_conf_path}}/{{item.name}}.conf" mode: 0644 with_items: "{{nginx_vhosts}}" - when: nginx_vhosts|length > 0 + when: nginx_vhosts | length > 0 notify: - reload nginx -# TODO: use find module once we move to 2.0 - name: Find config files in nginx_conf_path - shell: find {{nginx_conf_path}} -name '*.conf' -type f -printf '%f\n'|sed 's/.conf//' + find: paths={{nginx_conf_path}} patterns='*.conf' register: all_nginx_vhost_confs - name: Remove un-managed config files file: path: "{{nginx_conf_path}}/{{item}}.conf" state: absent - with_items: "{{all_nginx_vhost_confs.stdout_lines|default([])}}" - when: item not in nginx_vhosts|map(attribute='name')|list + with_items: "{{all_nginx_vhost_confs.files | default([]) | map(attribute='path') | list}}" + when: (item | basename | splitext | first) not in (nginx_vhosts | map(attribute='name') | list) notify: - reload nginx From 722c3044fadc7beb361033e40b4feb0bbd1421e4 Mon Sep 17 00:00:00 2001 From: Colin Hoglund Date: Wed, 12 Apr 2017 17:33:22 -0400 Subject: [PATCH 2/2] use correct path for vhosts --- tasks/vhosts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 195b7b04..66684d7c 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -15,7 +15,7 @@ - name: Remove un-managed config files file: - path: "{{nginx_conf_path}}/{{item}}.conf" + path: "{{item}}" state: absent with_items: "{{all_nginx_vhost_confs.files | default([]) | map(attribute='path') | list}}" when: (item | basename | splitext | first) not in (nginx_vhosts | map(attribute='name') | list)