use certificates role instead of letsencrypt role

This commit is contained in:
nd 2019-11-01 20:02:41 +01:00
parent f79fec1356
commit 53a4544ba1
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9
6 changed files with 27 additions and 2 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
__pycache__

17
filter_plugins/filters.py Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env python3
class FilterModule(object):
def filters(self):
return {
'nginx_vhosts_to_certificates': self.nginx_vhosts_to_certificates
}
def nginx_vhosts_to_certificates(self, vhosts):
certs = {}
for i in vhosts.keys():
if not vhosts[i]['letsencrypt']:
continue
certs['nginx_'+i] = {
'backend': 'letsencrypt',
'san': vhosts[i]['servername']
}
return certs

View file

@ -2,3 +2,4 @@
dependencies: dependencies:
- { role: monitoring, when: nginx.monitoring } - { role: monitoring, when: nginx.monitoring }
- { role: pki-server, when: nginx.serverpki } - { role: pki-server, when: nginx.serverpki }
- certificates

View file

@ -5,6 +5,9 @@
- delete nginx index.nginx-debian.html - delete nginx index.nginx-debian.html
- restart nginx - restart nginx
- name: debugnginx
debug: var=certificates
- name: copy configs - name: copy configs
copy: copy:
src: config/ src: config/

View file

@ -61,8 +61,8 @@ server {
{% endfor %} {% endfor %}
{% if vhost.letsencrypt|d(False) %} {% if vhost.letsencrypt|d(False) %}
ssl_certificate /etc/ssl/letsencrypt_{{ vhost_name }}_chained.crt; ssl_certificate /etc/ssl/nginx_{{ vhost_name }}.chain.crt;
ssl_certificate_key /etc/ssl/private/letsencrypt_{{ vhost_name }}.key; ssl_certificate_key /etc/ssl/private/nginx_{{ vhost_name }}.key;
ssl_stapling_verify on; ssl_stapling_verify on;
ssl_stapling on; ssl_stapling on;
{% endif %} {% endif %}

View file

@ -3,3 +3,6 @@ monitoring:
checks: checks:
local: local:
nginx_status: {} nginx_status: {}
certificates:
certs: "{{ nginx.vhosts|nginx_vhosts_to_certificates }}"