From b686c6ae9ff18ca1ce8b8e602dc03548cbfa7b31 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 17 Oct 2026 21:23:25 -0700 Subject: Add better encapsulation to ansible roles - Replace a few of the global variables in the host inventory to explicit variables that we pass into the particular roles that need it. - Move slowcgi setup to cgit since that is where it is needed (instead of obsd_httpd) - Rename `acme_client` to `obsd_ssl` to better emphasize it is related to generating ssl certificates on openbsd. - Add support for multiple ssl certificates into `obsd_ssl` by looping over the new role variable it has --- roles/obsd_ssl/templates/acme-client.conf.j2 | 17 +++++++++++++++++ roles/obsd_ssl/templates/httpd.d/acme.conf | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 roles/obsd_ssl/templates/acme-client.conf.j2 create mode 100644 roles/obsd_ssl/templates/httpd.d/acme.conf (limited to 'roles/obsd_ssl/templates') diff --git a/roles/obsd_ssl/templates/acme-client.conf.j2 b/roles/obsd_ssl/templates/acme-client.conf.j2 new file mode 100644 index 0000000..cb53f34 --- /dev/null +++ b/roles/obsd_ssl/templates/acme-client.conf.j2 @@ -0,0 +1,17 @@ +authority letsencrypt { + api url "https://acme-v02.api.letsencrypt.org/directory" + account key "/etc/acme/letsencrypt-privkey.pem" +} + +authority letsencrypt-staging { + api url "https://acme-staging-v02.api.letsencrypt.org/directory" + account key "/etc/acme/letsencrypt-staging-privkey.pem" +} + +{% for domain in obsd_ssl_domains %} +domain "{{ domain }}" { + domain key "/etc/ssl/private/{{ domain }}.key" + domain full chain certificate "/etc/ssl/{{ domain }}.fullchain.pem" + sign with letsencrypt +} +{% endfor %} diff --git a/roles/obsd_ssl/templates/httpd.d/acme.conf b/roles/obsd_ssl/templates/httpd.d/acme.conf new file mode 100644 index 0000000..357a294 --- /dev/null +++ b/roles/obsd_ssl/templates/httpd.d/acme.conf @@ -0,0 +1,12 @@ +{% for domain in obsd_ssl_domains %} +server "{{ domain }}" { + listen on * port 80 + location "/.well-known/acme-challenge/*" { + root "/acme" + request strip 2 + } + location * { + block return 302 "https://$HTTP_HOST$REQUEST_URI" + } +} +{% endfor %} -- cgit v1.2.3