aboutsummaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-10-19 22:32:54 -0700
committerEugene Triguba <hello@eugenetriguba.com>2026-10-19 22:32:54 -0700
commit6cf0129d002d0bbc88756f4d662e0f5af043dc52 (patch)
tree45c56805d7f49e5f1977050f7fa6da81b8ec9138 /roles
parentRename cgit to git and acme to ssl for httpd (diff)
downloadsite-configs-6cf0129d002d0bbc88756f4d662e0f5af043dc52.zip
Add static site hosting for eugenetriguba.com
Diffstat (limited to 'roles')
-rw-r--r--roles/obsd_ssl/tasks/main.yml8
-rw-r--r--roles/obsd_ssl/templates/acme-client.conf.j29
-rw-r--r--roles/obsd_ssl/templates/httpd.d/ssl.conf2
-rw-r--r--roles/obsd_www/defaults/main.yml5
-rw-r--r--roles/obsd_www/files/index.html10
-rw-r--r--roles/obsd_www/tasks/main.yml25
-rw-r--r--roles/obsd_www/templates/httpd.d/www.conf.j212
7 files changed, 63 insertions, 8 deletions
diff --git a/roles/obsd_ssl/tasks/main.yml b/roles/obsd_ssl/tasks/main.yml
index d29c576..4a3b23f 100644
--- a/roles/obsd_ssl/tasks/main.yml
+++ b/roles/obsd_ssl/tasks/main.yml
@@ -33,9 +33,9 @@
when: acme_client_vhost_config is changed # noqa: no-handler
- name: Generate certificate
- ansible.builtin.command: acme-client {{ item }}
+ ansible.builtin.command: acme-client {{ item.name }}
args:
- creates: "/etc/ssl/{{ item }}.fullchain.pem"
+ creates: "/etc/ssl/{{ item.name }}.fullchain.pem"
loop: "{{ obsd_ssl_domains }}"
- name: Add certificate renewal crontab entry
@@ -45,8 +45,8 @@
# >
# > ~ * * * * acme-client example.com && rcctl reload httpd
ansible.builtin.cron:
- name: "renew {{ item }} certificate"
+ name: "renew {{ item.name }} certificate"
minute: "~"
user: root
- job: "acme-client {{ item }} && rcctl reload httpd"
+ job: "acme-client {{ item.name }} && rcctl reload httpd"
loop: "{{ obsd_ssl_domains }}"
diff --git a/roles/obsd_ssl/templates/acme-client.conf.j2 b/roles/obsd_ssl/templates/acme-client.conf.j2
index cb53f34..051e32c 100644
--- a/roles/obsd_ssl/templates/acme-client.conf.j2
+++ b/roles/obsd_ssl/templates/acme-client.conf.j2
@@ -9,9 +9,12 @@ authority letsencrypt-staging {
}
{% for domain in obsd_ssl_domains %}
-domain "{{ domain }}" {
- domain key "/etc/ssl/private/{{ domain }}.key"
- domain full chain certificate "/etc/ssl/{{ domain }}.fullchain.pem"
+domain "{{ domain.name }}" {
+ {% if domain.alternative_names is defined %}
+ alternative names { {{ domain.alternative_names | default([]) | join(' ') }} }
+ {% endif %}
+ domain key "/etc/ssl/private/{{ domain.name }}.key"
+ domain full chain certificate "/etc/ssl/{{ domain.name }}.fullchain.pem"
sign with letsencrypt
}
{% endfor %}
diff --git a/roles/obsd_ssl/templates/httpd.d/ssl.conf b/roles/obsd_ssl/templates/httpd.d/ssl.conf
index 357a294..0576580 100644
--- a/roles/obsd_ssl/templates/httpd.d/ssl.conf
+++ b/roles/obsd_ssl/templates/httpd.d/ssl.conf
@@ -1,5 +1,5 @@
{% for domain in obsd_ssl_domains %}
-server "{{ domain }}" {
+server "{{ domain.name }}" {
listen on * port 80
location "/.well-known/acme-challenge/*" {
root "/acme"
diff --git a/roles/obsd_www/defaults/main.yml b/roles/obsd_www/defaults/main.yml
new file mode 100644
index 0000000..0b631f4
--- /dev/null
+++ b/roles/obsd_www/defaults/main.yml
@@ -0,0 +1,5 @@
+obsd_domain:
+obsd_alias_domain:
+obsd_www_chroot: "/var/www"
+# Absolute path from /var/www chroot that httpd runs in
+obsd_www_htdocs_dir: /htdocs/www
diff --git a/roles/obsd_www/files/index.html b/roles/obsd_www/files/index.html
new file mode 100644
index 0000000..082fab9
--- /dev/null
+++ b/roles/obsd_www/files/index.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <title>Hello World</title>
+ </head>
+ <body>
+ <h1>Hello World!</h1>
+ </body>
+</html>
diff --git a/roles/obsd_www/tasks/main.yml b/roles/obsd_www/tasks/main.yml
new file mode 100644
index 0000000..91aefd1
--- /dev/null
+++ b/roles/obsd_www/tasks/main.yml
@@ -0,0 +1,25 @@
+- name: Create www htdocs dir
+ ansible.builtin.file:
+ path: "{{ obsd_www_chroot }}{{ obsd_www_htdocs_dir }}"
+ state: directory
+ owner: www
+ group: www
+ mode: "0775"
+
+- name: Add initial dummy index.html file (if one does not exist)
+ ansible.builtin.copy:
+ src: index.html
+ dest: "{{ obsd_www_chroot }}{{ obsd_www_htdocs_dir }}/index.html"
+ force: false
+ owner: root
+ group: wheel
+ mode: "0664"
+
+- name: Deploy www vhost fragment
+ ansible.builtin.template:
+ src: httpd.d/www.conf.j2
+ dest: "{{ obsd_httpd_conf_d }}/www.conf"
+ owner: root
+ group: wheel
+ mode: "0644"
+ notify: Reload httpd
diff --git a/roles/obsd_www/templates/httpd.d/www.conf.j2 b/roles/obsd_www/templates/httpd.d/www.conf.j2
new file mode 100644
index 0000000..76a9bd5
--- /dev/null
+++ b/roles/obsd_www/templates/httpd.d/www.conf.j2
@@ -0,0 +1,12 @@
+server "{{ obsd_domain }}" {
+ {% if obsd_alias_domain is defined %}
+ alias "{{ obsd_alias_domain }}"
+ {% endif %}
+ listen on egress tls port 443
+ tls {
+ certificate "/etc/ssl/{{ obsd_domain }}.fullchain.pem"
+ key "/etc/ssl/private/{{ obsd_domain }}.key"
+ }
+ root "/htdocs/www"
+ no banner
+}