Skip to content

Commit

Permalink
ansible: Make domain configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed Feb 16, 2024
1 parent 32a0f55 commit 85de5cc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 91 deletions.
6 changes: 2 additions & 4 deletions ansible/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ motis:
spline-vm-motis:
ansible_user: root
ansible_host: vm-motis.spline.de
cert_domains:
- transitous.jbb.ghsq.de
- api.transitous.jbb.ghsq.de
email: [email protected]
transitous_nginx_site_include_extra: /etc/ssl/routing.spline.inf.fu-berlin.de/include.nginx
transitous_domain: routing.spline.de
1 change: 1 addition & 0 deletions ansible/roles/motis/files/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ host=127.0.0.1
[import]
#paths=osm:europe-latest.osm.pbf
paths=osm:berlin-latest.osm.pbf
paths=schedule-de-longdistance:de-longdistance.fixed.zip
paths=schedule-de-berlin:vbb.fixed.zip
paths=schedule-lv-pv:pv.zip
paths=schedule-lv-rigas-satiksme:improved-gtfs-satiksme.zip
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/motis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

- name: Unpack MOTIS
unarchive:
src: https://github.com/motis-project/motis/releases/download/v0.11.16/motis-linux-amd64.tar.bz2
src: https://github.com/motis-project/motis/releases/download/v0.11.17/motis-linux-amd64.tar.bz2
dest: /opt/
remote_src: yes

Expand Down
21 changes: 0 additions & 21 deletions ansible/roles/nginx/files/api.transitous.jbb.ghsq.de.conf

This file was deleted.

29 changes: 0 additions & 29 deletions ansible/roles/nginx/files/transitous.jbb.ghsq.de.conf

This file was deleted.

41 changes: 5 additions & 36 deletions ansible/roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,16 @@
systemd:
name: nginx.service
state: started
#
# - name: Install certbot
# apt:
# name: certbot
#
# - name: Check if certificate already exists.
# stat:
# path: /etc/letsencrypt/live/{{ cert_domains | first | replace('*.', '') }}/cert.pem
# register: letsencrypt_cert
#
# - name: Generate new certificate if one doesn't exist.
# command: >-
# certbot certonly --noninteractive --agree-tos --dry-run
# --email {{ email }}
# -w /var/www/html/
# -d {{ cert_domains | join(',') }}
# --webroot
# --expand
# when: not letsencrypt_cert.stat.exists
#
# - name: Enable automatic certificate renewal
# service:
# name: certbot.timer
# enabled: true
# masked: false

- name: Install nginx config
copy:
src: nginx.conf
dest: /etc/nginx/nginx.conf

- name: Install site config
copy:
src: "{{ item }}.conf"
dest: "/etc/nginx/sites-available/{{ item }}.conf"
with_items:
- transitous.jbb.ghsq.de
- api.transitous.jbb.ghsq.de
template:
src: "transitous.conf.j2"
dest: "/etc/nginx/sites-available/transitous.conf"

- name: Disable default site configuration
file:
Expand All @@ -56,12 +28,9 @@

- name: Enable nginx sites
file:
src: "/etc/nginx/sites-available/{{ item }}.conf"
dest: "/etc/nginx/sites-enabled/{{ item }}.conf"
src: "/etc/nginx/sites-available/transitous.conf"
dest: "/etc/nginx/sites-enabled/transitous.conf"
state: link
with_items:
- transitous.jbb.ghsq.de
- api.transitous.jbb.ghsq.de

- name: Reload nginx
systemd:
Expand Down
28 changes: 28 additions & 0 deletions ansible/roles/nginx/templates/transitous.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2024 Jonah Brüchert <jbb@kaidan.im>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

server {
listen 443 http2 ssl;
listen [::]:443 http2 ssl;

include '{{ transitous_nginx_site_include_extra }}';

server_name {{ transitous_domain }};

location ~ ^/$ {
if ($arg_motis != https%3A%2F{{ transitous_domain }}%2Fapi) {
return 301 https://$host?motis=https%3A%2F{{ transitous_domain }}%2Fapi;
}

root /opt/motis/web/;
}

location / {
root /opt/motis/web/;
}

location /api/ {
proxy_pass http://localhost:8080/;
}
}

0 comments on commit 85de5cc

Please sign in to comment.