Verified Commit 4ba8647f authored by Boris Budini's avatar Boris Budini 🛡
Browse files

Initial commit

parents
- name: Install snapd
apt:
force_apt_get: yes
name: snapd
state: present
- name: install certbot
community.general.snap:
name: certbot
classic: yes
- name: create symlink
file:
path: /usr/bin/certbot
state: link
src: /snap/bin/certbot
- name: Generate a certificate
shell: "certbot certonly --nginx --agree-tos --email {{lets_encrypt_email}} -n -d {{inventory_hostname}}"
- name: Add the cron renewal
cron:
name: "Renew SSL"
minute: "0"
hour: "0"
job: "/usr/bin/certbot renew && systemctl reload nginx"
- name: add docker gpg-key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add docker repo
apt_repository:
repo: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable'
state: present
update_cache: yes
- name: Install list of packages
apt:
name: docker-ce
state: present
- name: Install docker driver
pip:
name: docker
- name: Add docker-compose
get_url:
url: "https://github.com/docker/compose/releases/download/{{docker_compose_version}}/docker-compose-Linux-x86_64"
dest: /usr/local/bin/docker-compose
mode: '0555'
version: "3"
services:
osrm:
container_name: osrm
image: osrm/osrm-backend
restart: always
ports:
- "5000:5000"
volumes:
- /opt/osrm-data:/data
command: "osrm-routed --max-matching-size 1000 --max-table-size 1000 --max-viaroute-size 1000 --algorithm mld /data/{{osrm_data_file}}.osrm"
vroom-backend:
network_mode: host
container_name: vroom-backend
image: vroomvrp/vroom-docker:v1.8.0
restart: always
depends_on:
- osrm
volumes:
- /opt/vroom:/conf
environment:
- VROOM_ROUTER=osrm # router to use, osrm or ors
vroom-frontend:
container_name: vroom-frontend
image: iedmrc/vroom-frontend
restart: always
ports:
- "9966:9966"
depends_on:
- osrm
- vroom-backend
volumes:
- /opt/vroom-frontend/api.js:/vroom-frontend/src/config/api.js
server {
listen 80;
server_name {{inventory_hostname}};
return 301 https://$host$request_uri;
}
server {
server_name {{inventory_hostname}};
location / {
proxy_pass http://127.0.0.1:9966/;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /osmr {
proxy_pass http://127.0.0.1:3000/;
proxy_set_header Host $http_host;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/{{inventory_hostname}}/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/{{inventory_hostname}}/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
cliArgs:
geometry: false # retrieve geometry (-g)
threads: 1 # number of threads to use (-t)
explore: 5 # exploration level to use (0..5) (-x)
limit: '100mb' # max request size
logdir: '/..' # the path for the logs relative to ./src
maxlocations: 1000 # max number of jobs/shipments locations
maxvehicles: 200 # max number of vehicles
override: true # allow cli options override (-g, -t and -x)
path: '' # VROOM path (if not in $PATH)
port: 3000 # expressjs port
router: 'osrm' # routing backend (osrm, libosrm or ors)
timeout: 300000 # milli-seconds
baseurl: '/' #base url for api
routingServers:
osrm:
car:
host: '0.0.0.0'
port: '5000'
'use strict';
module.exports = {
tileLayer: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
host: 'https://{{inventory_hostname}}/osmr',
port: '',
maxJobNumber: 1000
};
---
- hosts: "{{host}}"
vars_prompt:
- name: "host"
prompt: "host"
private: no
vars:
lets_encrypt_email: "email@example.com"
osrm_data_file: "berlin-latest"
docker_compose_version: "1.29.2"
remote_user: root
tasks:
- name: Run nginx
import_tasks: nginx.yml
- name: Run certbot
import_tasks: certbot.yml
- name: Install docker
import_tasks: docker.yml
- name: Install osrm
import_tasks: osrm.yml
- name: Install vroom
import_tasks: vroom.yml
- name: template docker-compose config
template:
src: files/docker-compose.yml
dest: /opt/docker-compose.yml
- name: restart nginx to load new config
ansible.builtin.systemd:
state: restarted
name: nginx
- name: Start stack
shell: /usr/local/bin/docker-compose -f /opt/docker-compose.yml up -d
- name: Install nginx
apt:
name: nginx
state: present
- name: create workdir
file:
path: /opt/osrm-data
state: directory
- name: download osrm file
get_url:
url: "http://download.geofabrik.de/europe/germany/{{osrm_data_file}}.osm.pbf"
dest: /opt/osrm-data
- name: Start osrm-extract
community.docker.docker_container:
name: osrm-extract
image: osrm/osrm-backend
state: started
detach: no
auto_remove: yes
volumes:
- /opt/osrm-data:/data
command: "osrm-extract -p /opt/car.lua /data/{{osrm_data_file}}.osm.pbf"
- name: remove pbf file
file:
path: "/opt/osrm-data/{{osrm_data_file}}.osm.pbf"
state: absent
- name: Start osrm-partition
community.docker.docker_container:
name: osrm-partition
image: osrm/osrm-backend
state: started
detach: no
auto_remove: yes
volumes:
- /opt/osrm-data:/data
command: "osrm-partition /data/{{osrm_data_file}}.osrm"
- name: Start osrm-customize
community.docker.docker_container:
name: osrm-customize
image: osrm/osrm-backend
state: started
detach: no
auto_remove: yes
volumes:
- /opt/osrm-data:/data
command: "osrm-customize /data/{{osrm_data_file}}.osrm"
- name: create vroom workdir
file:
path: /opt/vroom
state: directory
- name: Copy config file
ansible.builtin.copy:
src: files/vroom-config.yml
dest: /opt/vroom/config.yml
- name: create vroom-frontend workdir
file:
path: /opt/vroom-frontend
state: directory
- name: Template vroom-frontend
template:
src: files/vroom-frontend-config.yml
dest: /opt/vroom-frontend/api.js
- name: template nginx config
template:
src: files/nginx
dest: /etc/nginx/sites-enabled/default
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment