Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#30 Local digitransit setup #3

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# ansible

PLAYBOOK_CMD:=ANSIBLE_PIPELINING=true ansible-playbook --vault-password-file vault-password
PLAYBOOK_CMD:=ANSIBLE_PIPELINING=true ansible-playbook --vault-password-file vault-password

galaxy-install:
ansible-galaxy collection install -r requirements.yml
Expand Down Expand Up @@ -91,3 +91,7 @@ photon-local:
photon-remote:
. venv/bin/activate
ansible-playbook -i inventory-remote.yml photon-playbook.yml

digitransit-local:
${PLAYBOOK_CMD} -i ride2go-inventory.yml digitransit.yml

27 changes: 27 additions & 0 deletions Modifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## vault secret:
- you need to have vault-secret file in the digitransit-ansible directory
## ride2go-inventory:
- you should change the ip address according to the address of the machine you want to install it on.
## MakeFile:
- new command for running digitransit.yml with custom inventory
## digitransit.yml
- commented out every role except `base` and `digitransit`
## variables
- created `vars/main.yml` for both `base` and `digitransit` role and assigned variables needed (with dummy content until changed)
## dependencies
- commented out geerlingguy.certbot dependencies and requirements
## docker-compose
- removed unneccessary parts related to the ui
## digitransit/main.yml
- commented out parts relating to the ui
## docker-compose.yml
- deleted encryption key and the UI part (everything between "services:" and "network:")
## all.yml
- commented out vaulted variables (they are unused variables, and causes encryption error)
- disabled unused services (prediction, gtfs, etc..)
## roles/base/main.yml
- removed send to matrix script
## docker-compose.yml
- changed image to `mfdz/opentripplanner:latest` (from d38...)
- changed otp_docker_tag to latest aswell.

54 changes: 54 additions & 0 deletions Photon&OTP_usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# **Photon**

# Path
If you're accessing photon from within the VM or machine its running on, then your path for the requests will be:
- `curl "http://localhost:2322/api"`

Accessing Photon and making requests from outside the environment, you will need to adjust the path accordingly, and make the path accessable from outside the VM.
# Requests
You can make requests with the `?q` keyword for query. A basic search looks like this:
- curl "http://localhost:2322/api?q=berlin"

For the Searches to work as intented with autocempletition, using the correct language, we need several parameters in the request to show results accordingly.

The following keywords will have to be filled out based on the website front end information:
- `&lang` for Language
- `&lon` for longitude
- `&lat` for latitude

Language:

We have to get the selected language from the front end, to pass to the back-end request as an argument.

For example if we have German language selected, the request should be:
- curl "http://localhost:2322/api?q=berlin&lang=de"

Location based searching, relevant results from the same area:

- If we need exact location based searching, and we access the users location, we can pass the the coordinates from the users login into the request.
- If we only want to give relevant searches based on the selected language, we should use the general coordinates according to each country.
Info:https://git.gerhardt.io/gi/devops/issues/42#issuecomment-597

Example for searches based on language:
```
switch language
case "de":
longitude=10
latitude=51
case "hu":
longitude=19
latitude=47
...
request = 'curl "http://localhost:2322/api?q=$searchQuery&lon=$l&lat=55.5123" '
...
(make the request, collect results)
```
# OpenTripPlanner
For OTP, requests require coordinates (from, to) to find a trip between the locations.

An example request for OTP from within the environment looks like the following:
- `curl "http://localhost:8080/otp/routers/default/plan?fromPlace=48.776277,9.182863&toPlace=46.2564158,20.1508822&mode=WALK,TRANSIT&maxWalkDistance=2000&arriveBy=false&wheelchair=false&locale=en" `

If we have the previously selected search results, we can store the values of the selected destination, and pass the coordinates as variables to the OTP request.

Additional parameters for the search like `mode of transport`, or `arriveBy` can be filled out with variables that contain the settings passed from the front-end.
115 changes: 115 additions & 0 deletions PhotonDetailed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# **Photon standalone**

## **In the Local Machine:**
- **Create VM by following the InstallVMGuide.md file (in the gi/devops from Codeberg):**
- https://codeberg.org/gi/devops/src/branch/main/gitea/Documentations/InstallVMGuide.md
- 64GB ram
- 8 cores
- 150G storage

- **Ask VM's IP address after Installation of the VM:**
- Log in in the terminal:
- `<username>` and `password`
- `ip address`
- Save the IP address

- **Open the terminal and use the ssh-copy-id command for not typing the password after ssh:**
- `ssh-copy-id -i ~/.ssh/id_rsa.pub <username>@IP`
- Type username's password

## **In the VM:**
- **Add sudo permission to user of vm:**
- Give the sudo permission to the user in the terminal as root:
- https://phpraxis.wordpress.com/2016/09/27/enable-sudo-without-password-in-ubuntudebian/
- `su -l`
- `adduser <user> sudo`
- `apt-get install sudo`
- `sudo visudo /etc/sudoers`
- `<username> ALL=(ALL) NOPASSWD:ALL` to **the end of file**
- `%sudo ALL=(ALL) NOPASSWD:ALL`
- `logout` or `exit`
- `sudo apt-get install curl`

## **In the Local Machine:**
- **Open the new terminal:**
- `cd ~/Desktop`
- `mkdir git`
- `cd git`
- `git clone https://github.com/fahrgemeinschaft/digitransit-ansible.git`
- `ċd digitransit-ansible`

- **Create virtual environment and install certain packages:**
- `python3 -m virtualenv venv`
- `. venv/bin/activate`
- `pip3 install -r requirements.txt`
- `ansible --help`

- **Add user to sudo group:**
- `su` # enter root password here
- `/sbin/usermod -aG sudo <username>`

- **Normal user should be able to run sudo commands without PW prompt**
- `su` # enter root password here
- `sudo visudo` /etc/sudoers
- `username ALL=(ALL) NOPASSWD:ALL` to **the end of file**
- `logout` or `exit`

- **Install geerlingguy.docker:**
- `ansible-galaxy install geerlingguy.docker`

- **Add user to docker group:**
- `sudo groupadd docker`
- `su` # enter root password here
- `/sbin/usermod -aG docker <username>`

## If you want to use it on a local vm or direct IP connection:
- **Change ip address and hostname on the certain files:**
- `nano inventory-local.yml`
- `nano ansible-playbook.yml` OR `nano photon-playbook.yml`

- **Run the playbook:**
- `make photon-local`
## If you want to use it on a remote machine or with hostname:
- Add ssh configuration on your local machine, if it requires multiple ssh, use proxyjump too:
- `nano .ssh/config` on your local computer
```bash
Host services1
HostName 162.55.99.187
User ride2go
Port 38765
IdentityFile ~/.ssh/gi-student

Host photon-services1
ProxyJump services1
HostName 192.168.122.91
User ride2go
Port 22
IdentityFile ~/.ssh/gi-student
```

- **Change hostname on the certain files:**
- `nano inventory-remote.yml`
- `nano photon-playbook.yml`

- **Run the playbook:**
- `make photon-remote`

- **Add VM user to docker group after playbook successfully ran for the first time:**
- `su` # enter root password here
- `/sbin/usermod -aG docker <username>`

- **Open the new terminal again:**
- `ssh <username>@IP`
- `docker ps`
- **Take the first 3 character of the nominatim**
- `docker logs $3_character -f`
- **Wait until the LOG shows the line:** (It may takes 40 minutes)
- **database system is ready to accept connections**
- `sudo service photon start`
- `docker ps`
- **Take the first 3 character of the photon**
- `docker logs $3_character -f`
- **Wait until the LOG shows the line:** (It may takes 5 minutes)
- **de.komoot.photon.App - ES cluster is now ready.**
- After them you can call the API with:
- `curl "http://localhost:2322/api/?q=stuttgart&lang=de"`
8 changes: 4 additions & 4 deletions digitransit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
become: yes
roles:
- base
- delay-prediction-service
#- delay-prediction-service
- digitransit
- thingsboard-enhancer
- thingsboard-to-mqtt
- matomo
#- thingsboard-enhancer
#- thingsboard-to-mqtt
#- matomo
Loading