Skip to content

Commit

Permalink
Merge pull request #1 from singleplatform-eng/use_find_module_when_cl…
Browse files Browse the repository at this point in the history
…eaning_vhosts

use find module when cleaning vhosts
  • Loading branch information
Colin Hoglund authored Apr 13, 2017
2 parents c4a7b39 + 722c304 commit 3ee545c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 5 additions & 6 deletions tasks/vhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
path: "{{item}}"
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

0 comments on commit 3ee545c

Please sign in to comment.