aboutsummaryrefslogtreecommitdiffstats
path: root/roles/web/tasks/nginx-gensites.yml
blob: daea8758effe712398338bb781d6e140b19006a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
- name: domains - check certificate existence
  stat:
    path: "{{ web.ssl_root }}/{{ item.name }}/fullchain"
  register: stat
  with_items: "{{ domains }}"

- name: domains - save certificate status in a variable
  set_fact:
    domains_hascert: >
      {{ domains_hascert |
         default({}) |
         combine({item.0.name: item.1.stat.exists}) }}
  with_together:
    - "{{ domains }}"
    - "{{ stat.results }}"

- debug: var=domains_hascert

- name: nginx - generate sites
  template:
    src: "{{ item }}"
    dest: /usr/local/etc/nginx/sites/{{ item | basename | regex_replace('\.j2', '') }}
  # NOTE: `with_fileglob` always operates from `files/`
  with_fileglob:
    - "../templates/sites/*.j2"
  notify: reload-nginx