-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1407 from roots/fix-warnings-for-missing-paths
Fix warnings for missing paths
- Loading branch information
Showing
3 changed files
with
69 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,64 @@ | ||
--- | ||
- name: Build list of Nginx includes templates | ||
find: | ||
paths: | ||
- "{{ nginx_includes_templates_path }}" | ||
pattern: "*.conf.j2" | ||
recurse: yes | ||
- stat: | ||
path: "{{ nginx_includes_templates_path }}" | ||
become: no | ||
delegate_to: localhost | ||
register: nginx_includes_templates | ||
register: nginx_includes_local_directory | ||
|
||
- name: Create includes.d directories | ||
file: | ||
path: "{{ nginx_path }}/includes.d/{{ item }}" | ||
state: directory | ||
mode: '0755' | ||
with_items: "{{ nginx_includes_templates.files | map(attribute='path') | | ||
map('regex_replace', nginx_includes_pattern, '\\2') | | ||
map('dirname') | unique | list | sort | ||
}}" | ||
when: nginx_includes_templates.files | count | ||
- block: | ||
- name: Build list of Nginx includes templates | ||
find: | ||
paths: "{{ nginx_includes_templates_path }}" | ||
pattern: "*.conf.j2" | ||
recurse: yes | ||
become: no | ||
delegate_to: localhost | ||
register: nginx_includes_templates | ||
|
||
- name: Template files out to includes.d | ||
template: | ||
src: "{{ item }}" | ||
dest: "{{ nginx_path }}/includes.d/{{ item | regex_replace(nginx_includes_pattern, '\\2') }}" | ||
mode: '0644' | ||
with_items: "{{ nginx_includes_templates.files | map(attribute='path') | list | sort(True) }}" | ||
notify: reload nginx | ||
- name: Create includes.d directories | ||
file: | ||
path: "{{ nginx_path }}/includes.d/{{ item }}" | ||
state: directory | ||
recurse: yes | ||
mode: '0755' | ||
with_items: "{{ nginx_includes_templates.files | map(attribute='path') | | ||
map('regex_replace', nginx_includes_pattern, '\\2') | | ||
map('dirname') | unique | list | sort | ||
}}" | ||
when: nginx_includes_templates.files | count | ||
|
||
- name: Retrieve list of existing files in includes.d | ||
find: | ||
paths: "{{ nginx_path }}/includes.d" | ||
pattern: "*.conf" | ||
recurse: yes | ||
register: nginx_includes_existing | ||
when: nginx_includes_d_cleanup | bool | ||
- name: Template files out to includes.d | ||
template: | ||
src: "{{ item }}" | ||
dest: "{{ nginx_path }}/includes.d/{{ item | regex_replace(nginx_includes_pattern, '\\2') }}" | ||
mode: '0644' | ||
with_items: "{{ nginx_includes_templates.files | map(attribute='path') | list | sort(True) }}" | ||
notify: reload nginx | ||
when: nginx_includes_local_directory.stat.isdir is defined | ||
|
||
- name: Cleanup old unmanaged Nginx includes | ||
block: | ||
- stat: | ||
path: "{{ nginx_path }}/includes.d" | ||
register: nginx_includes_directory | ||
|
||
- name: Remove unmanaged files from includes.d | ||
file: | ||
path: "{{ item }}" | ||
state: absent | ||
with_items: "{{ nginx_includes_existing.files | default({}) | map(attribute='path') | | ||
difference(nginx_includes_templates.files | map(attribute='path') | | ||
map('regex_replace', nginx_includes_pattern, nginx_path + '/includes.d/\\2') | unique | ||
) | list | ||
}}" | ||
when: nginx_includes_d_cleanup | ||
notify: reload nginx | ||
- name: Retrieve list of existing files in includes.d | ||
find: | ||
paths: "{{ nginx_path }}/includes.d" | ||
pattern: "*.conf" | ||
recurse: yes | ||
register: nginx_includes_existing | ||
when: nginx_includes_directory.stat.isdir is defined | ||
|
||
- name: Remove unmanaged files from includes.d | ||
file: | ||
path: "{{ item }}" | ||
state: absent | ||
with_items: "{{ nginx_includes_existing.files | default({}) | map(attribute='path') | | ||
difference(nginx_includes_templates.files | default({} )| map(attribute='path') | | ||
map('regex_replace', nginx_includes_pattern, nginx_path + '/includes.d/\\2') | unique | ||
) | list | ||
}}" | ||
when: nginx_includes_directory.stat.isdir is defined | ||
notify: reload nginx | ||
when: nginx_includes_d_cleanup | bool |