Add hopglass-frontend role
This commit is contained in:
parent
a341ff4260
commit
bc6edb2ca3
10 changed files with 183 additions and 0 deletions
|
@ -2,3 +2,5 @@ basics_autoupdate_origins:
|
|||
- o=Node Source,n=${distro_codename}
|
||||
- o=Prosody,n=${distro_codename}
|
||||
- o=TorProject,n=${distro_codename}
|
||||
hopglass_frontend_tls_crt: /etc/letsencrypt/live/hopglass.hamburg.freifunk.net/fullchain.pem
|
||||
hopglass_frontend_tls_key: /etc/letsencrypt/live/hopglass.hamburg.freifunk.net/privkey.pem
|
||||
|
|
|
@ -7,6 +7,9 @@ srv04 ansible_host=srv04.hamburg.freifunk.net
|
|||
[certsync]
|
||||
srv03
|
||||
|
||||
[hopglass-frontend]
|
||||
srv02
|
||||
|
||||
[updates]
|
||||
srv01
|
||||
srv03
|
||||
|
|
3
roles/hopglass-frontend/defaults/main.yml
Normal file
3
roles/hopglass-frontend/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
hopglass_frontend_path: /opt/hopglass-frontend
|
||||
nodejs_version: node_8.x
|
41
roles/hopglass-frontend/tasks/install-hopglass.yml
Normal file
41
roles/hopglass-frontend/tasks/install-hopglass.yml
Normal file
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
- name: clone hopglass
|
||||
git:
|
||||
repo: "https://github.com/hopglass/hopglass"
|
||||
dest: "{{ hopglass_frontend_path }}"
|
||||
accept_hostkey: yes
|
||||
update: no
|
||||
|
||||
- name: create build directory
|
||||
file:
|
||||
path: "{{ hopglass_frontend_path }}/build"
|
||||
state: directory
|
||||
|
||||
- name: template config.json
|
||||
template:
|
||||
src: hopglass-config.j2
|
||||
dest: "{{ hopglass_frontend_path }}/build/config.json"
|
||||
|
||||
- name: template nginx site
|
||||
template:
|
||||
src: nginx-site.j2
|
||||
dest: /etc/nginx/conf.d/hopglass.conf
|
||||
register: nginx
|
||||
|
||||
- name: reload nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
when: nginx.changed
|
||||
|
||||
- name: template make-hopglass-frontend
|
||||
template:
|
||||
src: make-hopglass-frontend.j2
|
||||
dest: /usr/local/bin/make-hopglass-frontend
|
||||
mode: 0755
|
||||
register: make
|
||||
|
||||
- name: show usage information
|
||||
debug:
|
||||
msg: ">>> Because Node.js is terrible, please run make-hopglass-frontend manually. <<<"
|
||||
when: make.changed
|
33
roles/hopglass-frontend/tasks/install-nodejs.yml
Normal file
33
roles/hopglass-frontend/tasks/install-nodejs.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
- name: check for npm
|
||||
find:
|
||||
paths: [/bin, /usr/bin, /usr/local/bin]
|
||||
patterns: npm
|
||||
file_type: any
|
||||
register: npm
|
||||
|
||||
- name: install APT HTTPS transport
|
||||
apt:
|
||||
name: apt-transport-https
|
||||
cache_valid_time: 86400
|
||||
when: npm.matched == 0
|
||||
|
||||
- name: add NodeSource signing key
|
||||
apt_key:
|
||||
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
|
||||
id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280
|
||||
when: npm.matched == 0
|
||||
|
||||
- name: add NodeSource repository
|
||||
apt_repository:
|
||||
repo: "deb https://deb.nodesource.com/{{ nodejs_version }} {{ ansible_lsb.codename }} main"
|
||||
filename: nodesource
|
||||
when: npm.matched == 0
|
||||
|
||||
- name: install Node.js
|
||||
apt:
|
||||
name:
|
||||
- build-essential
|
||||
- nodejs
|
||||
cache_valid_time: 86400
|
||||
when: npm.matched == 0
|
5
roles/hopglass-frontend/tasks/main.yml
Normal file
5
roles/hopglass-frontend/tasks/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- include: install-nodejs.yml
|
||||
tags: nodejs
|
||||
- include: install-hopglass.yml
|
||||
tags: hopglass-frontend
|
49
roles/hopglass-frontend/templates/hopglass-config.j2
Normal file
49
roles/hopglass-frontend/templates/hopglass-config.j2
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"dataPath": "https://map.hamburg.freifunk.net/hhneu/",
|
||||
"siteName": "Freifunk Hamburg",
|
||||
"mapSigmaScale": 1.1,
|
||||
"showContact": false,
|
||||
"maxAge": 30,
|
||||
"mapLayers": [
|
||||
{
|
||||
"name": "OpenStreetMap",
|
||||
"url": "https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png",
|
||||
"config": {
|
||||
"maxZoom": 18,
|
||||
"attribution": "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Satellitenbild",
|
||||
"url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
|
||||
"config": {
|
||||
"attribution": "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodeInfos": [
|
||||
{
|
||||
"name": "Clientstatistik",
|
||||
"href": "https://statistik.hamburg.freifunk.net/dashboard/db/freifunk-knoteninfo-knoten-id?var-region=ffhh&var-knoten={NODE_ID}",
|
||||
"thumbnail": "https://statistik.hamburg.freifunk.net/render/dashboard-solo/db/freifunk-knoteninfo-knoten-id?panelId=1&var-region=ffhh&var-knoten={NODE_ID}&theme=light&width=530&height=332&from=now-3d",
|
||||
"caption": "Verbundene Clients in den letzten 3 Tage an Knoten {NODE_ID}"
|
||||
}
|
||||
],
|
||||
"globalInfos": [
|
||||
{
|
||||
"name": "Clientstatistik (gesamt)",
|
||||
"href": "https://statistik.hamburg.freifunk.net/dashboard/db/freifunk-ubersicht?var-region=ffhh",
|
||||
"thumbnail": "https://statistik.hamburg.freifunk.net/render/dashboard-solo/db/freifunk-ubersicht?panelId=1&var-region=ffhh&theme=light&width=530&height=332&from=now-3d",
|
||||
"caption": "Verbundene Clients in den letzten 3 Tagen"
|
||||
}
|
||||
],
|
||||
"linkInfos": [],
|
||||
"siteNames": [
|
||||
{ "site": "ffhh", "name": "Hamburg" },
|
||||
{ "site": "ffhh-nowe", "name": "Hamburg-NordWest" },
|
||||
{ "site": "ffhh-ost", "name": "Hamburg-Ost" },
|
||||
{ "site": "ffhh-sued", "name": "Hamburg-Sued" },
|
||||
{ "site": "ffhh-west", "name": "Hamburg-West" }
|
||||
],
|
||||
"hwImg": []
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
cd {{ hopglass_frontend_path }}
|
||||
npm install
|
||||
npm install grunt-cli
|
||||
node_modules/.bin/grunt
|
35
roles/hopglass-frontend/templates/nginx-site.j2
Normal file
35
roles/hopglass-frontend/templates/nginx-site.j2
Normal file
|
@ -0,0 +1,35 @@
|
|||
{% if hopglass_frontend_tls_crt is defined %}
|
||||
server {
|
||||
server_name hopglass.hamburg.freifunk.net;
|
||||
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
ssl_certificate {{ hopglass_frontend_tls_crt }};
|
||||
ssl_certificate_key {{ hopglass_frontend_tls_key }};
|
||||
|
||||
include include/no_logging.conf;
|
||||
include include/ssl_common_headers.conf;
|
||||
|
||||
gzip on;
|
||||
gzip_types application/json;
|
||||
root {{ hopglass_frontend_path }}/build;
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
server {
|
||||
server_name hopglass.hamburg.freifunk.net;
|
||||
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
include include/letsencrypt.conf;
|
||||
include include/no_logging.conf;
|
||||
{% if hopglass_frontend_tls_crt is defined %}
|
||||
include include/ssl.rewrite;
|
||||
{% else %}
|
||||
|
||||
gzip on;
|
||||
gzip_types application/json;
|
||||
root {{ hopglass_frontend_path }}/build;
|
||||
{% endif %}
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
---
|
||||
- hosts: hopglass-frontend
|
||||
roles:
|
||||
- hopglass-frontend
|
||||
|
||||
- hosts: services
|
||||
roles:
|
||||
- ntp-server
|
||||
|
|
Loading…
Reference in a new issue