aboutsummaryrefslogtreecommitdiffstats
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
parentRename cgit to git and acme to ssl for httpd (diff)
downloadsite-configs-6cf0129d002d0bbc88756f4d662e0f5af043dc52.zip
Add static site hosting for eugenetriguba.com
-rw-r--r--README.md23
-rw-r--r--ansible.cfg4
-rwxr-xr-xbootstrap.sh13
-rw-r--r--inventory/git.yml5
-rw-r--r--inventory/group_vars/all.yml2
-rw-r--r--inventory/www.yml3
-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
-rwxr-xr-xrun-playbook.sh5
-rw-r--r--site.yml20
15 files changed, 111 insertions, 35 deletions
diff --git a/README.md b/README.md
index d0a0ebd..c54cfd9 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,33 @@
-# git.eugenetriguba.com Configurations
+# *.eugenetriguba.com Configurations
-This Ansible playbook sets up my git server at https://git.eugenetriguba.com.
+This Ansible playbook sets up my web server at https://eugenetriguba.com and git
+server at https://git.eugenetriguba.com.
-It is intended to be run against an OpenBSD server. It will then setup:
+It is intended to be run against OpenBSD servers.
+For the git server, it will setup:
- A web server with OpenBSD's `httpd`
- A SSL certificate for the host with OpenBSD's `acme-client` and Let's
Encrypt
- A git user to own the git data
- cgit as the UI for the git data
- Automated backups via `restic` and Backblaze's B2 service
+- A web server with OpenBSD's `httpd` to serve files from /var/www/htdocs/www
## Usage
-If you want to use this playbook for your own git server, you'll want to update
-`inventory/git.yml` to give the details of your own server and `site.yml` to
-pass in the variable values that make sense for your use case.
+If you want to use this playbook for your own servers, you'll want to update
+`inventory/` files to give the details of your own server and the `site.yml`
+playbook to pass in the variable values that make sense for your use case.
-Once that is done, you may run:
+To ensure you have the right Ansible and its collections installed, run:
```sh
./bootstrap.sh
```
+
+Then, you can run a playbook with:
+
+```sh
+./run-playbook.sh ./site.yml
+```
diff --git a/ansible.cfg b/ansible.cfg
index f522d9f..aa38981 100644
--- a/ansible.cfg
+++ b/ansible.cfg
@@ -1,6 +1,6 @@
[defaults]
-inventory = inventory/git.yml
-roles_path = roles
+inventory = inventory/
+roles_path = roles/
interpreter_python = auto_silent
[privilege_escalation]
diff --git a/bootstrap.sh b/bootstrap.sh
index 55b22ae..be0f4b7 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,13 +1,10 @@
#!/bin/sh
-set -e
-
-PLAYBOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
-PLAYBOOK="${PLAYBOOK_DIR}/site.yml"
+set -o errexit
+set -o nounset
main() {
ensure_ansible_installed
ensure_ansible_collections_installed
- run_playbook "$@"
}
ensure_ansible_installed() {
@@ -35,12 +32,6 @@ ensure_ansible_collections_installed() {
fi
}
-run_playbook() {
- log_step "Running playbook"
- ansible-playbook --ask-become-pass --ask-vault-pass "$PLAYBOOK" "$@"
- log_step "Done!"
-}
-
bin_exists() {
command -v "$1" >/dev/null 2>&1
}
diff --git a/inventory/git.yml b/inventory/git.yml
index 473bb85..9c41dde 100644
--- a/inventory/git.yml
+++ b/inventory/git.yml
@@ -1,6 +1,3 @@
-all:
+git:
hosts:
git.eugenetriguba.com:
- vars:
- ansible_user: admin
- ansible_python_interpreter: /usr/local/bin/python3
diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml
new file mode 100644
index 0000000..f6d9582
--- /dev/null
+++ b/inventory/group_vars/all.yml
@@ -0,0 +1,2 @@
+ansible_user: admin
+ansible_python_interpreter: /usr/local/bin/python3
diff --git a/inventory/www.yml b/inventory/www.yml
new file mode 100644
index 0000000..29a3ace
--- /dev/null
+++ b/inventory/www.yml
@@ -0,0 +1,3 @@
+www:
+ hosts:
+ eugenetriguba.com:
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
+}
diff --git a/run-playbook.sh b/run-playbook.sh
new file mode 100755
index 0000000..100c750
--- /dev/null
+++ b/run-playbook.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -o errexit
+set -o nounset
+
+ansible-playbook --ask-vault-pass --ask-become-pass "$@"
diff --git a/site.yml b/site.yml
index 6dbea39..365947d 100644
--- a/site.yml
+++ b/site.yml
@@ -1,5 +1,5 @@
-- name: OpenBSD Git Server
- hosts: all
+- name: OpenBSD Server
+ hosts: git
become: true
vars_files:
- vars/secrets.yml
@@ -9,10 +9,18 @@
obsd_httpd_fragments:
- ssl.conf
- git.conf
+ - www.conf
- role: obsd_ssl
vars:
obsd_ssl_domains:
- - git.eugenetriguba.com
+ - name: git.eugenetriguba.com
+ - name: eugenetriguba.com
+ alternative_names:
+ - www.eugenetriguba.com
+ - role: obsd_www
+ vars:
+ obsd_domain: eugenetriguba.com
+ obsd_alias_domain: www.eugenetriguba.com
- role: obsd_git
vars:
obsd_git_authorized_keys:
@@ -26,3 +34,9 @@
restic_backups_b2_key_secret: "{{ vault_b2_key_secret }}"
restic_backups_repository: "{{ vault_restic_repository }}"
restic_backups_password: "{{ vault_restic_password }}"
+ tasks:
+ - name: Ensure admin user can access git and www files
+ ansible.builtin.user:
+ name: admin
+ groups: git,www
+ append: yes