diff --git a/roles/caddy/defaults/main.yml b/roles/caddy/defaults/main.yml index f32c03f..58d1881 100644 --- a/roles/caddy/defaults/main.yml +++ b/roles/caddy/defaults/main.yml @@ -7,3 +7,6 @@ website_path: /srv/http gitea_domain: "git.{{ domain }}" + +## send renewal reminders to this address +email: null diff --git a/roles/caddy/tasks/main.yml b/roles/caddy/tasks/main.yml index f5ff787..06842c6 100644 --- a/roles/caddy/tasks/main.yml +++ b/roles/caddy/tasks/main.yml @@ -9,6 +9,14 @@ template: src: Caddyfile.j2 dest: /etc/caddy/Caddyfile + lstrip_blocks: true + register: caddy_config + +- name: Restart Caddy service + service: + name: caddy + state: restarted + when: caddy_config.changed - name: Enable Caddy service service: diff --git a/roles/caddy/templates/Caddyfile.j2 b/roles/caddy/templates/Caddyfile.j2 index f54dd27..d24d330 100644 --- a/roles/caddy/templates/Caddyfile.j2 +++ b/roles/caddy/templates/Caddyfile.j2 @@ -1,12 +1,18 @@ +{ + {% if email is not none %} + email {{ email }} + {% endif %} +} + {% if "website" in group_names %} -www.{{ domain }} { +http://www.{{ domain }} { root * {{ website_path }} file_server } {% endif %} -{% if groups["gitea"] %} -{{ gitea_domain }} { +{% if groups["gitea"] | length > 0 %} +http://{{ gitea_domain }} { reverse_proxy {{ groups["gitea"][0] }}:3000 } {% endif %} diff --git a/roles/website/templates/deploy.sh.j2 b/roles/website/templates/deploy.sh.j2 index 06ef608..8a408bc 100644 --- a/roles/website/templates/deploy.sh.j2 +++ b/roles/website/templates/deploy.sh.j2 @@ -3,5 +3,5 @@ set -e -git -C /home/{{ web_username }}/website pull -make -C /home/{{ web_username }}/website build +git -C /home/{{ website_username }}/website pull +make -C /home/{{ website_username }}/website build