Roles: add service-nginx-openlayers

This commit is contained in:
Julian Labus 2019-02-13 11:40:25 +01:00
parent 026844de30
commit 3dbcb8f2c5
No known key found for this signature in database
GPG key ID: 8AF209F2C6B3572A
7 changed files with 106 additions and 0 deletions

View file

@ -12,6 +12,7 @@ http_meshviewer_prefix: map
http_grafana_prefix: stats http_grafana_prefix: stats
http_lookingglass_prefix: lg http_lookingglass_prefix: lg
http_prometheus_prefix: prom http_prometheus_prefix: prom
http_openlayers_prefix: ol
prometheus_conf_main: prometheus/prometheus.yml.j2 prometheus_conf_main: prometheus/prometheus.yml.j2

View file

@ -0,0 +1,18 @@
# Ansible role service-nginx-openlayers
Diese Ansible role installert OpenLayers und konfiguriert den nginx vHosts.
- schreibt openlayers.conf
- legt OpenLayers Verzeichnis an
- installert OpenLayers
## Benötigte Variablen
- Variable `openlayers_src` (Rollen Variable)
- Variable `openlayers_path` (Rollen Variable)
- Variable `openlayers_version` (Rollen Variable)
- Variable `http_openlayers_external` (Rollen Variable)
- Variable `http_openlayers_internal` (Rollen Variable)
- Variable `http_openlayers_prefix` # string: Subdomain
- Variable `http_domain_external` # string: Externe Freifunk MWU Domain
- Variable `http_domain_internal` # string: Interne Freifunk MWU Domain

View file

@ -0,0 +1,5 @@
---
- name: restart nginx
systemd:
name: nginx
state: restarted

View file

@ -0,0 +1,3 @@
---
dependencies:
- { role: service-nginx }

View file

@ -0,0 +1,42 @@
---
- name: create directory
file:
path: "{{ openlayers_path }}"
state: directory
mode: 0755
owner: www-data
group: www-data
- name: download and extract
unarchive:
creates: "{{ openlayers_path }}/{{ openlayers_version }}"
src: "{{ openlayers_src }}"
dest: "{{ openlayers_path }}"
remote_src: yes
owner: www-data
group: www-data
- name: create symlinks
file:
src: "{{ openlayers_version }}/{{ item }}"
dest: "{{ openlayers_path }}/{{ item }}"
state: link
loop:
- build
- css
- name: write vhost
template:
src: openlayers_vhost.conf.j2
dest: /etc/nginx/conf.d/openlayers.conf
owner: root
group: root
mode: 0644
notify: restart nginx
- name: fix permissions
file:
path: "{{ openlayers_path }}"
owner: www-data
group: www-data
recurse: yes

View file

@ -0,0 +1,30 @@
server {
listen 80;
listen [::]:80;
server_name {{ http_openlayers_external }} {{ http_openlayers_internal }};
include /etc/nginx/snippets/gzip.conf;
include /etc/nginx/snippets/letsencrypt-acme-challenge.conf;
root {{ openlayers_path }};
location / {
autoindex on;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name {{ http_openlayers_external }} {{ http_openlayers_internal }};
ssl_certificate /etc/nginx/ssl/{{ inventory_hostname_short }}.{{ http_domain_external }}/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/{{ inventory_hostname_short }}.{{ http_domain_external }}/privkey.pem;
include /etc/nginx/snippets/gzip.conf;
include /etc/nginx/snippets/letsencrypt-acme-challenge.conf;
root {{ openlayers_path }};
location / {
autoindex on;
}
}

View file

@ -0,0 +1,7 @@
---
http_openlayers_external: "{{ http_openlayers_prefix }}.{{ http_domain_external }}"
http_openlayers_internal: "{{ http_openlayers_prefix }}.{{ http_domain_internal }}"
openlayers_version: "v5.3.0"
openlayers_path: "/var/www/{{ http_openlayers_external }}"
openlayers_src: "https://github.com/openlayers/openlayers/releases/download/{{ openlayers_version }}/{{ openlayers_version }}.zip"