mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 03:32:12 +00:00
Merge pull request #2201 from holta/osm-split
Refine @jvonau's osm-split PR #2199
This commit is contained in:
commit
650d28c0ce
9 changed files with 169 additions and 103 deletions
|
@ -30,7 +30,7 @@
|
|||
|
||||
- name: Add 'captiveportal' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: captiveportal
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
- name: Add 'munin' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: munin
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=/osm-vector-maps/maplist/" />
|
||||
</head>
|
||||
|
||||
|
|
32
roles/osm-vector-maps/tasks/enable-or-disable.yml.deprecated
Normal file
32
roles/osm-vector-maps/tasks/enable-or-disable.yml.deprecated
Normal file
|
@ -0,0 +1,32 @@
|
|||
# This depends on iiab-admin-console which is not yet installed
|
||||
#- name: Run the script that does osm-vector-maps housekeeping
|
||||
# shell: /usr/bin/iiab-update-map
|
||||
|
||||
- name: Copy countries.json (geojson) to {{ vector_map_path }}/maplist/assets
|
||||
copy:
|
||||
src: countries.json
|
||||
dest: "{{ vector_map_path }}/maplist/assets" # /library/www/osm-vector-maps
|
||||
|
||||
# It is too complicated to use a single file for both iiab and admin-console
|
||||
- name: Copy map_functions.js (duplicated JavaScript) to {{ vector_map_path }}/maplist/assets
|
||||
copy:
|
||||
src: map_functions.js
|
||||
dest: "{{ vector_map_path }}/maplist/assets" # /library/www/osm-vector-maps
|
||||
|
||||
- name: Install {{ vector_map_path }}/maplist/index.html from template, for test page http://box/maps/maplist
|
||||
template:
|
||||
src: index.html
|
||||
dest: "{{ vector_map_path }}/maplist/index.html" # /library/www/osm-vector-maps
|
||||
|
||||
#- name: Does the {{ vector_map_path }}/index.html redirect already exist?
|
||||
# stat:
|
||||
# path: "{{ vector_map_path }}/index.html"
|
||||
# register: osm_redirect
|
||||
|
||||
#Copy the redirect to the test page -- delete this later if more than one map
|
||||
- name: Install {{ vector_map_path }}/index.html redirect for http://box/maps -> http://box/osm-vector-maps
|
||||
copy:
|
||||
force: no
|
||||
src: test-index.redirect
|
||||
dest: "{{ vector_map_path }}/index.html" # /library/www/osm-vector-maps
|
||||
#when: not osm_redirect.stat.exists
|
74
roles/osm-vector-maps/tasks/install.yml
Normal file
74
roles/osm-vector-maps/tasks/install.yml
Normal file
|
@ -0,0 +1,74 @@
|
|||
- name: Ensure directory {{ vector_map_path }}/maplist/assets exists
|
||||
file:
|
||||
path: "{{ vector_map_path }}/maplist/assets" # /library/www/osm-vector-maps
|
||||
state: directory
|
||||
owner: "{{ apache_user }}" # Typically 'www-data' or 'apache'
|
||||
group: "{{ apache_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Download map catalog {{ iiab_map_url }}/assets/regions.json to {{ vector_map_path }}/maplist/assets/
|
||||
get_url:
|
||||
url: "{{ iiab_map_url }}/assets/regions.json" # http://download.iiab.io/content/OSM/vector-tiles/maplist/hidden
|
||||
dest: "{{ vector_map_path }}/maplist/assets/" # /library/www/osm-vector-maps
|
||||
|
||||
- name: Symlink catalog {{ doc_root }}/common/assets/regions.json -> {{ vector_map_path }}/maplist/assets/regions.json
|
||||
file:
|
||||
src: "{{ vector_map_path }}/maplist/assets/regions.json" # /library/www/osm-vector-maps
|
||||
dest: "{{ doc_root }}/common/assets/regions.json" # /library/www/html
|
||||
state: link
|
||||
|
||||
- name: Download the JavaScript bundle with OpenLayers (main.js) into {{ vector_map_path }}/maplist/, for test page http://box/maps/maplist
|
||||
get_url:
|
||||
url: "{{ iiab_map_url }}/../main.js" # http://download.iiab.io/content/OSM/vector-tiles/maplist/hidden
|
||||
dest: "{{ vector_map_path }}/maplist/" # /library/www/osm-vector-maps
|
||||
|
||||
- name: Install {{ vector_map_path }}/maplist/index.html from template, for test page http://box/maps/maplist/
|
||||
template:
|
||||
src: index.html
|
||||
dest: "{{ vector_map_path }}/maplist/index.html" # /library/www/osm-vector-maps
|
||||
|
||||
# Bboxes (bounding boxes) are currently square. But geofabrik has non-rectangular bboxes.
|
||||
# So bring the bounding box definition from cloud (bboxes.geojson is big)
|
||||
- name: Download bounding box definitions (bboxes.geojson) to {{ vector_map_path }}/maplist/assets/
|
||||
get_url:
|
||||
url: "{{ iiab_map_url }}/assets/bboxes.geojson" # http://download.iiab.io/content/OSM/vector-tiles/maplist/hidden
|
||||
dest: "{{ vector_map_path }}/maplist/assets/" # /library/www/osm-vector-maps
|
||||
|
||||
- name: Install /usr/bin/iiab-update-map from template, for updating of Map Pack catalog & descriptions
|
||||
template:
|
||||
src: iiab-update-map
|
||||
dest: /usr/bin/iiab-update-map
|
||||
mode: '0755'
|
||||
|
||||
|
||||
# 2020-01-27: See #2197 "OSM Install Errors" -- should the following 4 stanzas
|
||||
# be restored to enable-or-disable.yml ? What fix is best short/long term?
|
||||
|
||||
- name: Copy countries.json (geojson) into {{ vector_map_path }}/maplist/assets/
|
||||
copy:
|
||||
src: countries.json
|
||||
dest: "{{ vector_map_path }}/maplist/assets" # /library/www/osm-vector-maps
|
||||
|
||||
# It is too complicated to use a single file for both iiab and admin-console
|
||||
- name: Copy map_functions.js (duplicated JavaScript) into {{ vector_map_path }}/maplist/assets/
|
||||
copy:
|
||||
src: map_functions.js
|
||||
dest: "{{ vector_map_path }}/maplist/assets" # /library/www/osm-vector-maps
|
||||
|
||||
- name: Install {{ vector_map_path }}/maplist/index.html from template, for test page http://box/maps/maplist/
|
||||
template:
|
||||
src: index.html
|
||||
dest: "{{ vector_map_path }}/maplist/index.html" # /library/www/osm-vector-maps
|
||||
|
||||
- name: "Copy test-index.redirect to {{ vector_map_path }}/index.html, for interim redirect: http://box/maps/ -> http://box/osm-vector-maps/maplist/"
|
||||
copy:
|
||||
force: no
|
||||
src: test-index.redirect
|
||||
dest: "{{ vector_map_path }}/index.html" # /library/www/osm-vector-maps
|
||||
|
||||
|
||||
- name: "Add 'osm_vector_maps_installed: True' to {{ iiab_state_file }}"
|
||||
lineinfile:
|
||||
dest: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
||||
regexp: '^osm_vector_maps_installed'
|
||||
line: 'osm_vector_maps_installed: True'
|
|
@ -1,106 +1,49 @@
|
|||
- name: Ensure directory {{ vector_map_path }}/maplist/assets exists
|
||||
file:
|
||||
path: "{{ vector_map_path }}/maplist/assets"
|
||||
state: directory
|
||||
owner: "{{ apache_user }}"
|
||||
group: "{{ apache_user }}"
|
||||
mode: '0755'
|
||||
# "How do i fail a task in Ansible if the variable contains a boolean value?
|
||||
# I want to perform input validation for Ansible playbooks"
|
||||
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
|
||||
|
||||
- name: Download map catalog {{ iiab_map_url }}/assets/regions.json to {{ vector_map_path }}/maplist/assets/
|
||||
get_url:
|
||||
url: "{{ iiab_map_url }}/assets/regions.json"
|
||||
dest: "{{ vector_map_path }}/maplist/assets/"
|
||||
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
|
||||
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
|
||||
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
|
||||
|
||||
- name: Symlink catalog {{ doc_root }}/common/assets/regions.json -> {{ vector_map_path }}/maplist/assets/regions.json
|
||||
file:
|
||||
src: "{{ vector_map_path }}/maplist/assets/regions.json"
|
||||
dest: "{{ doc_root }}/common/assets/regions.json"
|
||||
state: link
|
||||
- name: Assert that "osm_vector_maps_install is sameas true" (boolean not string etc)
|
||||
assert:
|
||||
that: osm_vector_maps_install is sameas true
|
||||
fail_msg: "PLEASE SET 'osm_vector_maps_install: True' e.g. IN: /etc/iiab/local_vars.yml"
|
||||
quiet: yes
|
||||
|
||||
- name: Download the JavaScript bundle with OpenLayers (main.js) for test page http://box/maps/maplist
|
||||
get_url:
|
||||
url: "{{ iiab_map_url }}/../main.js"
|
||||
dest: "{{ vector_map_path }}/maplist/"
|
||||
- name: Assert that "osm_vector_maps_enabled | type_debug == 'bool'" (boolean not string etc)
|
||||
assert:
|
||||
that: osm_vector_maps_enabled | type_debug == 'bool'
|
||||
fail_msg: "PLEASE GIVE VARIABLE 'osm_vector_maps_enabled' A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
|
||||
quiet: yes
|
||||
|
||||
- name: Install {{ vector_map_path }}/maplist/index.html from template, for test page http://box/maps/maplist
|
||||
template:
|
||||
src: index.html
|
||||
dest: "{{ vector_map_path }}/maplist/index.html"
|
||||
|
||||
# Bboxes (bounding boxes) are currently square. But geofabrik has non-rectangular bboxes.
|
||||
# So bring the bounding box definition from cloud (bboxes.geojson is big)
|
||||
- name: Download bounding box definitions (bboxes.geojson) to {{ vector_map_path }}/maplist/assets/
|
||||
get_url:
|
||||
url: "{{ iiab_map_url }}/assets/bboxes.geojson"
|
||||
dest: "{{ vector_map_path }}/maplist/assets/"
|
||||
- name: Install OSM Vector Maps if 'osm_vector_maps_installed' is not defined in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
|
||||
include_tasks: install.yml
|
||||
when: osm_vector_maps_installed is undefined
|
||||
|
||||
# REMOVE this stanza once the transition to Python 3 is confirmed
|
||||
#- name: Install python-geojson package (OS's prior to Ubuntu 19.10)
|
||||
# package:
|
||||
# name: python-geojson
|
||||
# state: present
|
||||
# when: is_raspbian_9 or is_raspbian_10 or is_ubuntu_16 or is_ubuntu_18 or is_debian_9 or is_debian_10
|
||||
|
||||
# 2019-10-19: Above python-geojson does not exist on Ubuntu 19.10, so let's
|
||||
# begin the transition to Python 3... currently unused
|
||||
#- name: Install python3-geojson package (especially for new OS's like Ubuntu 19.10+)
|
||||
# package:
|
||||
# name: python3-geojson # 2019-10-19: available across most/all recent
|
||||
# state: present # OS's, but not yet used by osm-vector-maps code?
|
||||
#- name: Install countries.json, map_functions.js & 2 index.html's under-or-in {{ vector_map_path }}/maplist # /library/www/osm-vector-maps
|
||||
# include_tasks: enable-or-disable.yml
|
||||
|
||||
- name: Install /usr/bin/iiab-update-map from template, for updating of Map Pack catalog & descriptions
|
||||
template:
|
||||
src: iiab-update-map
|
||||
dest: /usr/bin/iiab-update-map
|
||||
mode: '0755'
|
||||
- name: Enable/Disable/Reload NGINX for OSM, if nginx_enabled
|
||||
include_tasks: nginx.yml
|
||||
when: nginx_enabled | bool
|
||||
|
||||
# This depends on iiab-admin-console which is not yet installed
|
||||
#- name: Run the script that does osm-vector-maps housekeeping
|
||||
# shell: /usr/bin/iiab-update-map
|
||||
|
||||
- name: Copy countries.json (geojson) to {{ vector_map_path }}/maplist/assets
|
||||
copy:
|
||||
src: countries.json
|
||||
dest: "{{ vector_map_path }}/maplist/assets"
|
||||
|
||||
# It is too complicated to use a single file for both iiab and admin-console
|
||||
- name: Copy the duplicated JavaScript (map_functions.js) to {{ vector_map_path }}/maplist/assets
|
||||
copy:
|
||||
src: map_functions.js
|
||||
dest: "{{ vector_map_path }}/maplist/assets"
|
||||
|
||||
- name: Install {{ nginx_conf_dir }}/osm-vector-maps.conf from template
|
||||
template:
|
||||
src: osm-vector-maps-nginx.conf
|
||||
dest: "{{ nginx_conf_dir }}/osm-vector-maps-nginx.conf"
|
||||
when: osm_vector_maps_enabled | bool
|
||||
|
||||
- name: Remove {{ nginx_conf_dir }}/osm-vector-maps.conf
|
||||
file:
|
||||
path: "{{ nginx_conf_dir }}/osm-vector-maps-nginx.conf"
|
||||
state: absent
|
||||
when: not osm_vector_maps_enabled
|
||||
|
||||
#- name: Does the {{ vector_map_path }}/index.html redirect already exist?
|
||||
# stat:
|
||||
# path: "{{ vector_map_path }}/index.html"
|
||||
# register: osm_redirect
|
||||
|
||||
#Copy the redirect to the test page -- delete this later if more than one map
|
||||
- name: Install {{ vector_map_path }}/index.html redirect for http://box/maps -> http://box/osm-vector-maps/maplist/ if no redirect exists
|
||||
copy:
|
||||
force: no
|
||||
src: test-index.redirect
|
||||
dest: "{{ vector_map_path }}/index.html"
|
||||
#when: not osm_redirect.stat.exists
|
||||
|
||||
- name: Reload 'nginx' systemd service
|
||||
systemd:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
||||
- name: "Add 'osm_vector_maps_installed: True' to {{ iiab_state_file }}"
|
||||
lineinfile:
|
||||
dest: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
||||
regexp: '^osm_vector_maps_installed'
|
||||
line: 'osm_vector_maps_installed: True'
|
||||
- name: Add 'osm-vector-maps' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: osm-vector-maps
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
with_items:
|
||||
- option: name
|
||||
value: OSM Vector Maps
|
||||
- option: description
|
||||
value: '"OpenStreetMap is like Google Maps but better, for schools especially, as it works offline and avoids all the advertising. Download detailed ''vector maps'' for an entire continent, or the entire world! Also includes 10+ zoom levels of satellite imagery!"'
|
||||
- option: installed
|
||||
value: "{{ osm_vector_maps_install }}"
|
||||
- option: enabled
|
||||
value: "{{ osm_vector_maps_enabled }}"
|
||||
|
|
16
roles/osm-vector-maps/tasks/nginx.yml
Normal file
16
roles/osm-vector-maps/tasks/nginx.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
- name: Enable http://box/maps & http://box/osm-vector-maps via NGINX, by installing {{ nginx_conf_dir }}/osm-vector-maps-nginx.conf from template
|
||||
template:
|
||||
src: osm-vector-maps-nginx.conf.j2
|
||||
dest: "{{ nginx_conf_dir }}/osm-vector-maps-nginx.conf"
|
||||
when: osm_vector_maps_enabled | bool
|
||||
|
||||
- name: Disable http://box/maps & http://box/osm-vector-maps via NGINX, by removing {{ nginx_conf_dir }}/osm-vector-maps-nginx.conf
|
||||
file:
|
||||
path: "{{ nginx_conf_dir }}/osm-vector-maps-nginx.conf"
|
||||
state: absent
|
||||
when: not osm_vector_maps_enabled
|
||||
|
||||
- name: Reload 'nginx' systemd service
|
||||
systemd:
|
||||
name: nginx
|
||||
state: reloaded
|
|
@ -1,12 +1,14 @@
|
|||
# For downloadable regional vector tilesets
|
||||
location /maps {
|
||||
rewrite ^/maps(.*)$ /osm-vector-maps$1;
|
||||
rewrite ^/maps(.*)$ /osm-vector-maps$1;
|
||||
}
|
||||
|
||||
location /osm-vector-maps {
|
||||
alias /library/www/osm-vector-maps;
|
||||
alias {{ vector_map_path }}; # /library/www/osm-vector-maps
|
||||
}
|
||||
|
||||
location ~ ^/osm-vector-maps/(.*)\.php(.*)$ {
|
||||
alias /library/www/osm-vector-maps/$1.php$2;
|
||||
alias {{ vector_map_path }}/$1.php$2; # /library/www/osm-vector-maps
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header Host $host;
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
- name: Add 'wordpress' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||
section: wordpress
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value | string }}"
|
||||
|
|
Loading…
Reference in a new issue