Fix SSL with multiple names

py3
Emilien Mantel 2020-02-04 11:07:21 +01:00
parent 8c3b1c7f13
commit d8f6088362
3 changed files with 10 additions and 3 deletions

View File

@ -41,9 +41,14 @@ def nginx_all_site_names(site):
return all_sites return all_sites
def nginx_search_by_ssl_name(sites, ssl_name): def nginx_search_by_ssl_name(sites, ssl_name):
if isinstance(ssl_name, list):
comp_ssl_name = ssl_name[0]
else:
comp_ssl_name = ssl_name
res = None res = None
for site in sites: for site in sites:
if site.has_key('ssl_name') and site['ssl_name'] == ssl_name: if site.has_key('ssl_name') and site['ssl_name'] == comp_ssl_name:
res = site res = site
break break
return res return res

View File

@ -43,7 +43,7 @@
{%- endif %} {%- endif %}
{%- endmacro %} {%- endmacro %}
{% macro ssl(ssl_name) %} {% macro ssl(ssl_name) %}
{% for sn in nginx_ssl_pairs if (sn.name is defined and sn.name == ssl_name) %} {% for sn in nginx_ssl_pairs if (sn.name is defined and (sn | nginx_site_name) == ssl_name) %}
ssl_certificate {{ sn | nginx_cert_path(nginx_ssl_dir) }}; ssl_certificate {{ sn | nginx_cert_path(nginx_ssl_dir) }};
ssl_certificate_key {{ sn | nginx_key_path(nginx_ssl_dir) }}; ssl_certificate_key {{ sn | nginx_key_path(nginx_ssl_dir) }};
{% endfor %} {% endfor %}

View File

@ -83,7 +83,9 @@
- name: 'test-ssl-selfsigned.local' - name: 'test-ssl-selfsigned.local'
self_signed: true self_signed: true
force: false force: false
- name: 'test-ssl-predeployed.local' - name:
- 'test-ssl-predeployed.local'
- 'test-multiple-name.local' # Hack: tests for acme with multiple name, without using acme
dest_key: "{{ int_ansible_ssl_dir }}/test.key" dest_key: "{{ int_ansible_ssl_dir }}/test.key"
dest_cert: "{{ int_ansible_ssl_dir }}/test.crt" dest_cert: "{{ int_ansible_ssl_dir }}/test.crt"
- name: 'test-ssl.local' - name: 'test-ssl.local'