moved force_ssl and self signed cert to tasks

This commit is contained in:
nd 2020-04-30 19:59:06 +02:00
parent b3aa2c6169
commit 6781423adf
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9
3 changed files with 19 additions and 22 deletions

View file

@ -2,12 +2,17 @@
- set_fact:
nginx_certs: "{{ nginx.vhosts|nginx_vhosts_to_certificates }}"
inventory_certs: "{{ certificates.certs|d({}) }}"
selfsigned_cert: "{ '{{ inventory_hostname }}': { 'backend': 'selfsigned' }}"
- include_role:
name: certificates
vars:
certificates:
certs: "{{ {}|combine(nginx_certs, inventory_certs, recursive=True) }}"
certs: "{{ {}|combine(selfsigned_cert|from_yaml, nginx_certs, inventory_certs, recursive=True) }}"
- debug:
verbosity: 1
var: nginx
- name: install nginx
apt: pkg=nginx
@ -74,16 +79,7 @@
src: "/etc/nginx/sites-available/{{ item.key }}"
path: "/etc/nginx/sites-enabled/{{ item.key }}"
state: link
with_dict: "{{ nginx.vhosts }}"
notify:
- restart nginx
- name: enable https redirect
file:
src: "/etc/nginx/sites-available/https-redirect"
path: "/etc/nginx/sites-enabled/https-redirect"
state: link
when: nginx.force_ssl
with_dict: "{{ {}|combine((nginx_forcessl_vhost if nginx.force_ssl else {}), nginx.vhosts, recursive=True) }}"
notify:
- restart nginx