diff --git a/roles/nginx/tasks/main.yaml b/roles/nginx/tasks/main.yaml index 2b1c3f5..820a99e 100644 --- a/roles/nginx/tasks/main.yaml +++ b/roles/nginx/tasks/main.yaml @@ -81,14 +81,15 @@ src: site.j2 dest: "/etc/nginx/sites-available/{{ item.server.file_name }}" with_items: "{{ nginx_sites }}" - + when: nginx_sites is defined and nginx_sites + - name: enable nginx configurations used for letsencrypt challenge file: path: "/etc/nginx/sites-enabled/{{ item.server.file_name }}" state: link src: "/etc/nginx/sites-enabled/{{ item.server.file_name }}" with_items: "{{ nginx_sites }}" - when: letsencrypt|bool and item.use_for_challenge is defined and item.use_for_challenge|bool + when: letsencrypt|bool and item.use_for_challenge is defined and item.use_for_challenge|bool and nginx_sites is defined and nginx_sites - name: restart nginx to start enabled configurations used for letsencrypt service: @@ -104,7 +105,7 @@ - name: provision ssl cert/key(s) with letsencrypt include: letsencrypt.yml with_items: "{{ nginx_sites }}" - when: letsencrypt|bool and item.letsencrypt is defined + when: letsencrypt|bool and item.letsencrypt is defined and nginx_sites is defined and nginx_sites - name: enable nginx configuration generated from standard template file: