aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-10-06 13:18:33 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-10-06 13:18:33 +0300
commit29eb2e6cc469d9534c2586e98b782f1879bd8c76 (patch)
treeef2d0bd53087b04bc395dd96d7f6da9bfe69b470
parent0bf8f1d7f9e477b2de52ab1e7aea000eff8666fe (diff)
Refactor, add certbot to cron
-rw-r--r--tasks/jail_ingress.yml20
-rw-r--r--templates/ingress/etc_crontab.j210
-rw-r--r--templates/ingress/usr_local_etc_nginx_nginx.conf.j2 (renamed from templates/usr_local_etc_nginx_nginx.conf.j2)0
3 files changed, 29 insertions, 1 deletions
diff --git a/tasks/jail_ingress.yml b/tasks/jail_ingress.yml
index 53b8f67..d5cb2e7 100644
--- a/tasks/jail_ingress.yml
+++ b/tasks/jail_ingress.yml
@@ -40,7 +40,7 @@
# generated by certbot. Certbot will fail validation if nginx.conf is configured too early.
- name: Configure nginx.conf
template:
- src: usr_local_etc_nginx_nginx.conf.j2
+ src: ingress/usr_local_etc_nginx_nginx.conf.j2
dest: /usr/local/jails/containers/ingress/usr/local/etc/nginx/nginx.conf
owner: root
group: wheel
@@ -64,3 +64,21 @@
service -j ingress nginx enable
service -j ingress nginx onestart
when: ingress_nginx_enabled.rc != 0
+
+- name: Set up crontab
+ template:
+ src: ingress/etc_crontab.j2
+ dest: /usr/local/jails/containers/ingress/etc/crontab
+ owner: root
+ group: wheel
+ mode: "0644"
+ vars:
+ # comma-separated list of sites
+ items: "{{ static_sites | selectattr('tls') | map(attribute='host') | join(',') }}"
+ register: jail_ingress_etc_crontab
+
+- name: Restart cron
+ service:
+ name: cron
+ state: restarted
+ when: jail_ingress_etc_crontab.changed
diff --git a/templates/ingress/etc_crontab.j2 b/templates/ingress/etc_crontab.j2
new file mode 100644
index 0000000..7308565
--- /dev/null
+++ b/templates/ingress/etc_crontab.j2
@@ -0,0 +1,10 @@
+# /etc/crontab - root's crontab for FreeBSD
+#
+#
+SHELL=/bin/sh
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+#
+#minute hour mday month wday who command
+
+# Update LetsEncrypt certificates every day at 2:00 AM
+0 2 * * * root certbot certonly --nginx -n -m jan@jantuomi.fi --agree-tos -d {{ items }}
diff --git a/templates/usr_local_etc_nginx_nginx.conf.j2 b/templates/ingress/usr_local_etc_nginx_nginx.conf.j2
index cee7878..cee7878 100644
--- a/templates/usr_local_etc_nginx_nginx.conf.j2
+++ b/templates/ingress/usr_local_etc_nginx_nginx.conf.j2