Skip to content

Commit

Permalink
Merge pull request #242 from chriszarate/nginx-provide-includes-frame…
Browse files Browse the repository at this point in the history
…work

Copy files/includes and populate templates/includes and add to includes.d.
  • Loading branch information
fullyint committed Aug 9, 2015
2 parents 7307437 + 309a5d8 commit 57e9d39
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions roles/wordpress-setup/tasks/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,29 @@
when: item.value.ssl.enabled and item.value.ssl.key is defined | default(False)

- name: Create includes.d directories
file: path="/etc/nginx/includes.d/{{ item.key }}" state=directory mode=0755
with_dict: wordpress_sites
file: path="/etc/nginx/includes.d/{{ item }}"
state=directory
mode=0755
with_items: wordpress_sites.keys()
register: nginx_includes_paths

- name: Template files out to includes.d
template: src="includes.d/{{ item }}"
dest="/etc/nginx/includes.d/{{ item[:-3] }}"
with_lines: "cd ../templates/includes.d && find {{ wordpress_sites.keys() | join(' ') }} -type f -name \\*.conf.j2 2>/dev/null || :"
register: nginx_includes_managed
notify: reload nginx

- name: Retrieve list of existing files in includes.d
shell: "find {{ nginx_includes_paths.results | map(attribute='path') | join(' ') }} -type f -name \\*.conf 2>/dev/null || :"
register: nginx_includes_existing
changed_when: false

- name: Remove unmanaged files from includes.d
file: path="{{ item }}"
state=absent
with_items: "{{ nginx_includes_existing.stdout_lines | difference(nginx_includes_managed.results | default([]) | map(attribute='item') | map('regex_replace', '(.*)\\.j2', '/etc/nginx/includes.d/\\\\1') | list) }}"
notify: reload nginx

- name: Create WordPress configuration for Nginx
template: src="wordpress-site.conf.j2"
Expand Down

0 comments on commit 57e9d39

Please sign in to comment.