Giter VIP home page Giter VIP logo

digitransit-ansible's Introduction

digitransit-ansible

Install stadtnavi's digitransit with ansible

  • make dev: connects to the dev host and applies the playbook there
  • make beta
  • make production
  • make infrastructure

Vault

Secrets are encrypted with ansible vault. In order to run the above playbooks you need to place a file called vault-password into the root of the repository

  • it's ignored by version control.

Please get in touch with @leonardehrenfried to get the decryption key to paste into this file.

Encrypting

In order to add a new encrpted variable, use the following command:

ansible-vault encrypt_string --vault-password-file vault-password super-secure-text --name=my_secret_var

This prints an encrypted variable in ansible's yml syntax which you can paste into one of the vars files.

Decrypting

The easiest way is to look at the decrypted value is to view it on a host where it has been deployed to, where it is stored in plain text.

Digitransit target host requirements

This playbook has been tested with a Debian Buster (10) target only.

In order to execute the ansible playbook you need a user on the target host and sudo must be installed (which is not the case when using the Debian minimal base image). You also must enable passwordless sudo

DNS

In order for the automatic TLS certificate generation to work, you need to configure a DNS entry for the host.

On top of the main DNS entry, you also need up to three other ones:

  • One that starts with api. which points to the exact same machine. This is used to proxy all non-UI related API requests to their corresponding docker containers.
  • One for matomo
  • If you want to install Photon on the server too, you need hostname for that too.

Configuration files

The digitransit configuration files, that don't live inside docker containers, are placed or symlinked into /etc/digitransit.

Timers

This playbook uses systemd timers as a replacement for cron jobs.

If you want to list them run systemctl list-timers.

As of May 2020 this list as follows:

systemctl list-timers 
NEXT                          LEFT          LAST                          PASSED               UNIT                           ACTIVATES
Thu 2020-05-14 12:18:00 CEST  20s left      Thu 2020-05-14 12:16:01 CEST  1min 38s ago         thingsboard-to-parkapi.timer   thingsboard-to-parkapi.service
Thu 2020-05-14 23:00:00 CEST  10h left      Wed 2020-05-13 23:00:01 CEST  13h ago              data-builder.timer             data-builder.service
Fri 2020-05-15 00:00:00 CEST  11h left      Thu 2020-05-14 00:00:01 CEST  12h ago              docker-prune.timer             docker-prune.service
Fri 2020-05-15 02:00:00 CEST  13h left      Thu 2020-05-14 02:00:01 CEST  10h ago              digitransit-restart.timer      digitransit-restart.service
Fri 2020-05-15 02:15:00 CEST  13h left      Thu 2020-05-14 02:15:02 CEST  10h ago              tilemaker.timer                tilemaker.service

Automatic graph builds

The script build-graph builds a new graph every night at 1 o'clock. This is controlled by the systemd timer graph-build and if you want to modify this, then edit graph-build.timer and graph-build.service.

Common tasks

Restarting digitransit

systemctl restart digitransit-docker-compose

This also checks if there are newer images available on dockerhub and downloads them prior to restarting.

It also cleanly stops and removes the containers. This is important because hsl-map-server cannot be stopped and restarted.

Restarting a single digitransit container

restart-digitransit-container digitransit-ui

Viewing logs

All logs are sent to journald for storage and automatic deletion. Here is a list of common journalctl commands.

  • Viewing all digitransit logs: journalctl -u digitransit-docker-compose.service
  • Viewing digitransit-ui logs: journalctl CONTAINER_NAME=digitransit-ui-hbnext
  • Viewing opentripplanner logs: journalctl CONTAINER_NAME=opentripplanner
  • Viewing graph-build logs: journalctl -u graph-build

Triggering a rebuild of the OTP graph

systemctl start graph-build

A build is run every night but sometimes you want to trigger it manually.

aliases

To see the complete list of useful aliases check out alias.sh.

Subtopics

digitransit-ansible's People

Contributors

beck-berry avatar derhuerst avatar hbruch avatar leonardehrenfried avatar lonvia avatar meromisi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

digitransit-ansible's Issues

Move to stadtnavi org

  • Add bot user for dockerhub
  • For every docker build, push to stadtnavi as well to allow smooth transition
  • Move digitansit-ansible to new Github org
  • In sensible scripts, switch docker repo to stadtnavi (except for otp)
  • Move digitransit-ui to new Github org
  • Activate Travis for new repo and check if PR notifications work
  • Create docker hub repo description pages

Report: Increase the importance of individual OSM node in Nominatim and Photon

We want to experiment with manually modifying the ranking of places returned by Photon. In our concrete example the search for "Ahrensburg" returns the city of Ahrensburg and then the two subway stations, but not the main train station - at least not ranked high enough. This is because the train station doesn't have a wikidata or wikipedia tag.

Therefore we want to experiment with manually changing the importance.

Connecting to the Nominatim DB

If you're ssh'ed into the host infrastracture.stadtnavi.eu you can use the following command line to connect to the nominatim DB:

psql -h localhost -p 5432 -U nominatim

The password required is in the ansible vault but is visiable in decrypted form in the file /etc/systemd/system/nominatim.service.

IntelliJ

If you have the professional version of IntelliJ you can also use that for inspecting the database. For this you need to set up SSH tunneling in the UI.

Screenshot from 2021-09-23 11-14-17
Screenshot from 2021-09-23 11-14-13

Queries

If you want to find your way around a little, you could use the following queries:

-- Ahrensburg West (U-Bahn)
select * from placex where osm_id = 6233764950;

-- Ahrensburg Ost (U-Bahn)
select * from placex where osm_id = 5196118052;

-- Ahrensburg (Deutsche Bahn)
select * from placex where osm_id = 3205295000;

Setting the importance

In the queries and in the Photon debug output you can see that the two subway station have a score of ~0.31. We want to set the importance to something above that.

(Hamburg main station has an importance of ~0.46, by the way.)

The following query will set the wikipedia tag to the one of the city of Ahrensburg. and set the indexing status to 2, meaning Photon will know that it needs to import the row:

update placex set extratags = extratags || hstore('wikipedia', 'en:Ahrensburg'), indexed_status = 2 where osm_id = 3205295000;

During Photon's import it also sets the indexed_status and this will retrigger a computation of the importance.

Updating Photon

Now that we have updated the DB we can then trigger a Photon reimport with:

sudo systemctl start photon-update.service

You this will return immediately as it only triggers the HTTP call to start the import. You can view the progress in the log with

journalctl -u photon -f

If you have only a few rows to import then it should complete within seconds.

Result

Searching for Ahrensburg will lead to the train station being ranked highest.

Screenshot from 2021-09-23 12-33-29

Add DNS entry for Photon

Right now Photon runs at https://photon-temp.leonard.io/, however we probably want a proper DNS entry for this.

@hbruch Please decide which one it is and add the entries. If you like the URL to be something like https://api.mfdz.de/photon/ then let me know and I will configure it.

Merge upstream tilemaker changes

Previously I removed the names of water bodies as they were way too prominent (#17) but upstream has some interesting fixes: they display the names based on the size of the lake/river.

This means that not every puddle shows up on the map which is what we want.

Acceptance criteria

  • Get the latest process-openmaptiles.lua file from upstream and merge their changes. Be careful not to overwrite 3737109
  • Check the changes in config-openmaptiles.json. This file also configures zoom levels but to be honest I haven't fully understood how it interacts with the lua file. We might need the changes, might not.

Tips:

  • make tileserver-kreis-boeblingen (https://www.openstreetmap.org/relation/62721) will give you a larger area to test. Of course computing this will take a while.
  • The changes regarding the size of features are quite new. If you are having problems, make sure that you've pulled the latest version of the docker image lehrenfried/tilemaker.

Post mortem: Matomo data loss on 2020-02-20

On 2020-02-21 @Beck-berry reported a problem with the Matomo installation on track.mfdz.de. The reported problem was a missing Matomo configuration file.

@leonardehrenfried analysed the the problem and found a problem with the systemd unit responsible for starting up and cleaning shutting down the docker-compose network for Matamo: the command docker-compose down -v was copied from the digitransit network. This however means that when shutting down or restarting Matomo its volumes deleted, as indicated by the -v option. This is the desired behaviour for digitransit as it has no persistent state and its hsl-map-server even needs the volumes to be deleted.

In 10b2145 @leonardehrenfried changed the shutdown procedure to issue docker-compose stop instead which shut be more gentle to the persistent containers' data.

On 2020-02-24 he tested the fix and Matomo indeed survives a restart of the systemd unit.

/cc @hbruch @meromisi

Names of train tracks are too prominent

Screenshot from 2020-06-02 11-55-55

The current map gives too much prominence to the names of train tracks. I have circled the problematic ones in the screenshot above.

Please investigate how to drastically reduce the amount of times it's displayed or completely remove them.

Note: these are not the names of lines but the name of the actual train tracks. I lived in village near Herrenberg until I was 20 and didn't know that these tracks even have a name, so they don't really add useful information.

Construction sites are too prominent in satellite mode

When you switch to the satellite map mode you can see that construction sites, tunnels and probably a few other types of roads, are too prominent.

Screenshot from 2020-07-06 12-39-43

This is not a OSM extraction issue but a problem with the map style in the file roles/tileserver-gl/templates/satellite-overlay.json.

Please check the tunnel and construction site style elements and adjust the opacity to match the rest of the roads.

Add correct AAAA record for thingsboard

The parkapi script that downloads data from thingsboard taking several minutes on the the staging server, even though on my laptop it runs in a few seconds.

I think I debugged the issue as blocked IPv6 connections. The Thingsboard host advertises an IPv6 address:

but connecting to it with IPV6 fails from the staging host:

curl https://<thingsboard-url>/api -6

With IPv4 this call is instant.

My theory: the python script tries for every request to use IPv6 but times out and then uses ipv4. Since there are a few calls to this host, the whole script takes several minutes.

Note: Connecting to the host ssh with IPv6 also times out.

@hbruch Can you please take care of this.

Edit: It's not down to blocked IPv6 connections, it's simply that the advertised AAAA record of thningsboard-server cannot be routed to. The AAAA record needs to be corrected or removed.

Add carpool feed with real URLs to the staging server

Question is what to use as the download URL of the GTFS feed that includes the URLs, which are sensitive data.

One solution would be to put it into a public bucket (perhaps Azure because the elevation data is also hosted there) and use an un-guessable URL which is encrypted in ansible vault.

We might want to add password authentication but in that case I would have to change the data-container repo as it assumes everything is freely downloadable.

Reminder: Also review current crawling/leak protection measures.

Make make vagrant work

I got this VM with 512 MB RAM
image
and not the more appropriate setup for libvirt as in the Vagrantfile
image

In fact I'd prefer using libvirt instead of VirtualBox but I could not find out how.

Investigate transparency of more types of tunnels

Holger has reported that tunnels near his house are not shown transparently:

image

Notes:

My feeling is that it's a different class of bridge/tunnel.

Add mfdz feed build

  • document systemd timers in README
  • hbg.merged.gtfs.zip contains 4 merged feeds

Add cifs-transformer to create road works in cifs-format

The new project stadtnavi/cifs-transformer generates a cifs.json which contains the BW road works as well as those published by the city of Herrenberg via CSV.

Currently, this file is generated periodically at https://data.mfdz.de/hbg/roadworks/cifs.json.

In a first step, this file should be used in the tilelive map layer.

In the second step, a systemd job should be added to digitransit-ansible which periodically (e.g. every 10min) publishes the cifs via api.*

Make pilot.mobil-in-herrenberg.de also a Debian 10 system

Whilst rolling out to production, a had to make changes to the ansible roles to make them compatible with Ubuntu 18.04, as the staging server is running Debian 10.

Whilst the changes are easy to do, it really defeats the point of a staging system, if they run different operation systems. We really should not find out on the production server, if a change is incompatible.

Acceptance criteria:

  • Change the production system to use Debian 10

Come up with a solution for the data-container tag problem

Right now, the installation on a completely fresh host will fail as the digitransit docker-compose requires the image mfdz/opentripplanner-data-container-hb:local.

You might ask why it doesn't use mfdz/opentripplanner-data-container-hb:latest. If you do that and do a docker-compose pull the remote tag will overwrite the local tag (the freshly build data container), even though it is way older.

Then why don't you push the freshly built data container to docker hub? Because it contains sensitive data about carpooling routes that we don't want to publish.

Possible solutions

  • When you first install digitransit on a host, download mfdz/opentripplanner-data-container-hb:latest and tag it locally as mfdz/opentripplanner-data-container-hb:local. You need to make sure though that this only happens at the very first time as otherwise you again overwrite the tag.

Bring back names of railway tracks, but only for very high zoom levels

I've asked the author of tilemaker about railway tracks and if he would welcome a PR that removes them. He said that he doesn't want to remove them but only display them starting at zoom level 14. Therefore we need to build upon #29.

Acceptance criteria

  • Bring back names of railway tracks.
  • Figure out how to set the zoom level for these names starting from level 14. The documentation might give you an overview. This commit might make it easier to do it in the lua file. But perhaps it's also possible to just use the process-openmaptiles.json.
  • Upstream the changes with before-and-after pictures in the PR.

Upstream construction works in tilemaker

Beki has sucessfully added the construction works to our map tiles. We would like the changes to process-openmaptiles.lua to be upstreamed to https://github.com/systemed/tilemaker/blob/master/resources/process-openmaptiles.lua

Note that since I took a copy of this file it has changed a bit so you cannot just copy our file back.

Acceptance criteria

Photon/nominatim upgrade plan

We need to get started with the nominatim and photon upgrades. I'm going to summarise the installation process here since there are quite a few steps required.

Nominatim

  • Use standard nominatim 3.7
  • Configure the the extra-tags import style with the following addition
{   "keys" : ["public_transport"],
    "values" : {
       "platform" : "main,fallback,with_name",
       "stop_position" : "main,fallback,with_name",
       "station" : "main,fallback,with_name"
    }
},
  • Initial nominatim import
  • Download https://data.mfdz.de/mfdz/nvbw_osm_matches.csv.gz
  • Import CSV stop data with ./nominatim_add_ifopt.py -i osm-nvbw-stop-matches.csv (with invalidate)
  • Nightly import run ./nominatim_add_ifopt.py osm-nvbw-stop-matches.csv (no invalidate!)

Photon

  • use current komoot/master with two PRs merged in:
  • start up Photon with the flag -extra-tags ref:IFOPT
  • run regular import
  • start Photon with -synonym-file

Did I miss something?

@lonvia @hbruch

Add matomo to digitransit server

@frankgerhardt has requested that Matomo be added to the ansible installation.

According to him it's a docker compose file with 3 containers in them:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
2faa4d965b23        matomo:fpm-alpine   "/entrypoint.sh php-…"   5 days ago          Up 5 days           9000/tcp               digitransit-matomo_app_1
16588c5cbf68        nginx:alpine        "nginx -g 'daemon of…"   5 days ago          Up 5 days           0.0.0.0:8080->80/tcp   digitransit-matomo_web_1
f727b18adc40        mariadb             "docker-entrypoint.s…"   5 days ago          Up 5 days           3306/tcp               digitransit-matomo_db_1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.