aboutsummaryrefslogtreecommitdiffstats
path: root/roles/web/tasks/nginx-gensites.yml
blob: 162a8f37857e8a40557eb7bbd6cfdff1f19dae31 (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: /usr/local/etc/ssl/acme/{{ item.name }}/fullchain.pem
  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