Initial commit
This commit is contained in:
commit
e3639cc94c
18 changed files with 680 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/*.zip
|
||||
/*.osm.pbf
|
||||
/*vault*
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "roles/mapserver/files/basemaps"]
|
||||
path = roles/mapserver/files/basemaps
|
||||
url = https://github.com/mapserver/basemaps
|
126
README.md
Normal file
126
README.md
Normal file
|
@ -0,0 +1,126 @@
|
|||
**Important : this playbook is quick'n dirty and work in progress. Carefully review before using it.**
|
||||
|
||||
This Ansible playbook aims at setting a MapServer tile server on a
|
||||
Debian 10 Buster, inspired by
|
||||
https://github.com/mapserver/mapserver/wiki/Rendering-OSM-data-on-Ubuntu-12.04
|
||||
and https://github.com/mapserver/basemaps.
|
||||
|
||||
Here is a rough view of what will be set up (note: even with the following little import, be sure to have 3-4GB of available storage):
|
||||
|
||||
```
|
||||
# Install PostgreSQL + PostGIS, Apache, the MapServer CGI, imposm
|
||||
apt install postgis apache2 mapserver-bin cgi-mapserver libapache2-mod-mapcache imposm
|
||||
# ...and some dev tools for the basemap
|
||||
apt install make unzip wget git
|
||||
|
||||
# Create a dedicated database user with its own database
|
||||
# (you can harden the password but remember to edit the basemap's Makefile)
|
||||
# (unfortunately, I didn't manage to configure all the tools to use the unix socket. Ping me if you succeeded!)
|
||||
su -c 'psql -c "CREATE USER osm WITH PASSWORD '"'"'osm'"'"';"' postgres
|
||||
su -c "psql -c 'CREATE DATABASE osm WITH OWNER osm;'" postgres
|
||||
su -c "psql -c 'CREATE EXTENSION postgis;' osm" postgres
|
||||
|
||||
# Download or clone an OSM basemap
|
||||
# (in case of trouble, this tuto was tested with the commit 0c21924a1b1d20cea3acf35fc46256d019877338)
|
||||
mkdir -p /srv/osm
|
||||
cd /srv/osm
|
||||
git clone "https://github.com/mapserver/basemaps"
|
||||
|
||||
# Initial (only needed once) download of worldwide shapefiles (~750MB)
|
||||
# (the two zip files can be copied on following hosts to avoid the download)
|
||||
cd basemaps/data
|
||||
make
|
||||
|
||||
# Generation
|
||||
# (here, you can customize the Makefile. For example the style (default, google, bing) and the database connection)
|
||||
cd ..
|
||||
make
|
||||
|
||||
# Finally, import data...
|
||||
mkdir /srv/osm/imposm
|
||||
cd /srv/osm/imposm
|
||||
|
||||
# Manually download some small .pbf files as a test
|
||||
wget https://download.geofabrik.de/australia-oceania/new-caledonia-latest.osm.pbf
|
||||
wget https://download.geofabrik.de/europe/iceland-latest.osm.pbf
|
||||
# ...and import in PostGIS
|
||||
imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --read new-caledonia-latest.osm.pbf
|
||||
imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --read --merge-cache iceland-latest.osm.pbf
|
||||
imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --connection=postgis://osm:osm@localhost:5432/osm --write
|
||||
imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --connection=postgis://osm:osm@localhost:5432/osm --optimize
|
||||
imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --connection=postgis://osm:osm@localhost:5432/osm --deploy-production-tables
|
||||
|
||||
# Configure Apache, MapServer and MapCache
|
||||
mkdir /srv/osm/mapcache
|
||||
cp -i /usr/share/doc/libapache2-mod-mapcache/examples/mapcache.xml /srv/osm/mapcache/
|
||||
# Change layer to 'default' and add a <MAP> pointer to the basemap, in mapcache > source > getmap > params
|
||||
# Remember to adapt 'osm-default.map' if you changed the style in the basemap's Makefile (google, bing)
|
||||
sed -i 's#^\([[:space:]]\+\)<LAYERS>.*</LAYERS>#\1<LAYERS>default</LAYERS>\n\1<MAP>/srv/osm/basemaps/osm-default.map</MAP>#' mapcache.xml
|
||||
# Modify the url to point to the local CGI
|
||||
sed -i 's#<url>.*#<url>http://localhost/cgi-bin/mapserv?</url>#' /srv/osm/mapcache/mapcache.xml
|
||||
# And configure Apache
|
||||
cd /etc/apache2
|
||||
a2enmod cgi
|
||||
a2disconf serve-cgi-bin.conf
|
||||
sed -i 's/Require all granted/Require local/' conf-available/serve-cgi-bin.conf
|
||||
sed -i 's%#Include conf-available/serve-cgi-bin.conf%Include conf-available/serve-cgi-bin.conf\n\tMapCacheAlias /mapcache "/srv/osm/mapcache/mapcache.xml"%' sites-available/000-default.conf
|
||||
apache2ctl configtest
|
||||
service apache2 restart
|
||||
```
|
||||
|
||||
You can test it at http://your.server.name.tld/mapcache/demo/
|
||||
|
||||
## Back to Ansible
|
||||
|
||||
Most of the configuration should be available in the inventory.
|
||||
|
||||
It is launched usually like this : `ansible-playbook site.yml`
|
||||
|
||||
If you want to override the passwords within a vault :
|
||||
```
|
||||
ansible-vault create vault.yml
|
||||
# vault.yml example (take variables' names from inventory, vars, ...) :
|
||||
# ---
|
||||
# password: mypass
|
||||
ansible-playbook -e @vault.yml --ask-vault-pass site.yml
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Prerequisites for the hosts
|
||||
Hosts should be accessible via SSH as the root user (else, add the usual
|
||||
`remote_user`/`become` instructions in ansible.cfg) and with the Python
|
||||
prerequisite of Ansible (usually `python-minimal`).
|
||||
|
||||
Only tested on Debian 10 amd64 so far, with Ansible 2.7.7.
|
||||
|
||||
Note : to test or to limit to one particular host :
|
||||
```
|
||||
ansible foo.bar.com -m ping
|
||||
ansible-playbook -l foo.bar.com -v -C -D site.yml
|
||||
```
|
||||
|
||||
## Directory layout
|
||||
|
||||
We follow (more or less) the recommendations of
|
||||
https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html
|
||||
with :
|
||||
- `site.yml` : master playbook
|
||||
- `ansible.cfg` and `inventory.yml` : the first one set up some default configurations and introduce the second one : the inventory.
|
||||
- `roles/common/`, `roles/fooapp/` : the roles with their tree `tasks/main.yml`, `files/`, `handlers/main.yml`, ...
|
||||
- `group_vars/group1.yml` and `host_vars/hostname1.yml` : variables dedicated to a group or a host respectively.
|
||||
|
||||
Note : contrary to some recommendations, I prefer to set some variables in
|
||||
the inventory instead of `host_vars` and `group_vars`. For a small playbook
|
||||
like this one, it seems acceptable and it makes it easier to look where to
|
||||
adapt.
|
||||
|
||||
## TODO
|
||||
|
||||
- better cross-platform compatibility
|
||||
- use osmosis ? Said to be better than imposm (warning: heavy Java dependencies...)
|
||||
- check disk space ?
|
||||
|
||||
## License
|
||||
|
||||
[CC-0](https://creativecommons.org/publicdomain/zero/1.0/)
|
32
ansible.cfg
Normal file
32
ansible.cfg
Normal file
|
@ -0,0 +1,32 @@
|
|||
# config file for ansible -- http://ansible.com/
|
||||
# ==============================================
|
||||
|
||||
# nearly all parameters can be overridden in ansible-playbook
|
||||
# or with command line flags. ansible will read ANSIBLE_CONFIG,
|
||||
# ansible.cfg in the current working directory, .ansible.cfg in
|
||||
# the home directory or /etc/ansible/ansible.cfg, whichever it
|
||||
# finds first
|
||||
|
||||
[defaults]
|
||||
|
||||
# some basic default values...
|
||||
|
||||
inventory = ./inventory.yml
|
||||
#remote_tmp = /tmp/.ansible
|
||||
remote_user = root
|
||||
transport = ssh
|
||||
remote_port = 22
|
||||
# We try not to load the hypervisor
|
||||
#forks = 2
|
||||
|
||||
# For the time being, we don't trigger handlers (for example
|
||||
# restart SSH after modifying its config) when an error
|
||||
# happened.
|
||||
# It is the default Ansible behaviour but I prefer to explicitly
|
||||
# set it here in case a change is needed later.
|
||||
force_handlers = False
|
||||
|
||||
#filter_plugins = ./plugins/filter_plugins
|
||||
|
||||
#[privilege_escalation]
|
||||
#become = True
|
8
inventory.yml
Normal file
8
inventory.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
all:
|
||||
hosts:
|
||||
mapserver1.xlii.si:
|
||||
basemaps_style: google
|
||||
|
||||
vars:
|
||||
# Default basemaps style
|
||||
basemaps_style: default
|
1
roles/mapserver/files/basemaps
Submodule
1
roles/mapserver/files/basemaps
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 0c21924a1b1d20cea3acf35fc46256d019877338
|
5
roles/mapserver/handlers/main.yml
Normal file
5
roles/mapserver/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
|
||||
- name: handlerRestartApache
|
||||
become: yes
|
||||
service: name=apache2 state=restarted enabled=yes
|
6
roles/mapserver/tasks/10_package-install.yml
Normal file
6
roles/mapserver/tasks/10_package-install.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
|
||||
- name: Install packages
|
||||
apt:
|
||||
name: "{{ packages_list }}"
|
||||
when: ansible_os_family == "Debian"
|
25
roles/mapserver/tasks/20_database-creation.yml
Normal file
25
roles/mapserver/tasks/20_database-creation.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
|
||||
- name: Create database user
|
||||
postgresql_user:
|
||||
name: osm
|
||||
password: osm
|
||||
become: yes
|
||||
become_user: postgres
|
||||
become_method: su
|
||||
|
||||
- name: Create database
|
||||
postgresql_db:
|
||||
name: osm
|
||||
owner: osm
|
||||
become: yes
|
||||
become_user: postgres
|
||||
become_method: su
|
||||
|
||||
- name: Add PostGIS extension to database
|
||||
postgresql_ext:
|
||||
db: osm
|
||||
name: postgis
|
||||
become: yes
|
||||
become_user: postgres
|
||||
become_method: su
|
66
roles/mapserver/tasks/30_basemaps.yml
Normal file
66
roles/mapserver/tasks/30_basemaps.yml
Normal file
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
|
||||
# We offer the possibility to host the basemaps repo in files/basemaps
|
||||
# as a git submodule.
|
||||
# note : currently, if this method is used, any remote modification is erased.
|
||||
- name: Check if the basemaps repo has been cloned in files/
|
||||
run_once: true
|
||||
local_action: stat path={{ role_path }}/files/basemaps/.git
|
||||
register: basemaps_locally_available
|
||||
|
||||
- name: Copy local basemaps to host
|
||||
copy:
|
||||
src: "{{ role_path}}/files/basemaps/"
|
||||
dest: /srv/osm/basemaps/
|
||||
when: basemaps_locally_available.stat.exists
|
||||
|
||||
- name: Clone basemaps
|
||||
git:
|
||||
repo: https://github.com/mapserver/basemaps
|
||||
dest: /srv/osm/basemaps
|
||||
when: basemaps_locally_available.stat.exists != True
|
||||
|
||||
|
||||
# This is usually a one shot. Unless no .zip file is in /data, we skip the whole thing.
|
||||
# Simply remove the .zip files in basemaps/data/ if you need to refresh it.
|
||||
- name: Check if basemaps/data has been initialized
|
||||
find:
|
||||
paths: /srv/osm/basemaps/data
|
||||
patterns: '*.zip'
|
||||
register: basemaps_data_zip_list
|
||||
|
||||
- name: Upload the local shapefiles, if available, to save some bandwidth to the OSM project
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: /srv/osm/basemaps/data/
|
||||
with_fileglob:
|
||||
# Let's get to the root of the playbook
|
||||
- "../../../*land-polygons*.zip"
|
||||
- "*land-polygons*.zip"
|
||||
when: basemaps_data_zip_list.matched == 0
|
||||
|
||||
- name: Initialize basemaps/data
|
||||
command: make
|
||||
args:
|
||||
chdir: /srv/osm/basemaps/data/
|
||||
when: basemaps_data_zip_list.matched == 0
|
||||
|
||||
|
||||
# Customize Makefile
|
||||
- name: Customize basemaps Makefile
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: /srv/osm/basemaps/Makefile
|
||||
backup: no
|
||||
with_first_found:
|
||||
- files:
|
||||
- "basemaps/Makefile.{{ ansible_fqdn }}.j2"
|
||||
- "basemaps/Makefile.j2"
|
||||
skip: true
|
||||
register: tmp
|
||||
|
||||
- name: Generate basemaps
|
||||
# It seems Make doesn't see a makefile's modification worth a rebuild, so we force it a bit.
|
||||
command: "{{ tmp.changed | ternary('make --always-make', 'make') }}"
|
||||
args:
|
||||
chdir: /srv/osm/basemaps/
|
49
roles/mapserver/tasks/40_imposm.yml
Normal file
49
roles/mapserver/tasks/40_imposm.yml
Normal file
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
|
||||
# Upload .osm.pbf files found at the root of the playbook or in the /files role's subfolder
|
||||
- name: Imposm - Upload any local .osm.pbf files
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: /srv/osm/imposm/
|
||||
with_fileglob:
|
||||
# Let's get to the root of the playbook
|
||||
- "../../../*.osm.pbf"
|
||||
- "*.osm.pbf"
|
||||
|
||||
# If the .osm.pbf files are not newer than the cache, we skip the whole thing.
|
||||
- name: Imposm - Check if there is already a cache
|
||||
stat:
|
||||
path: /srv/osm/imposm/imposm_relations.cache
|
||||
register: tmp
|
||||
- name: Imposm - List pbf files waiting to be imported
|
||||
command: find /srv/osm/imposm -iname '*.osm.pbf' {{ tmp.stat.exists | ternary('-newer imposm_relations.cache', '') }}
|
||||
args:
|
||||
chdir: /srv/osm/imposm
|
||||
register: imposm_pbf_list
|
||||
changed_when: False
|
||||
check_mode: no
|
||||
|
||||
- name: Imposm - Import each new files
|
||||
command: imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --read --merge-cache {{ item|quote }}
|
||||
args:
|
||||
chdir: /srv/osm/imposm
|
||||
loop: "{{ imposm_pbf_list.stdout_lines }}"
|
||||
|
||||
- name: Imposm - Write to database
|
||||
command: imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --connection=postgis://osm:osm@localhost:5432/osm --write
|
||||
args:
|
||||
chdir: /srv/osm/imposm
|
||||
when: imposm_pbf_list.stdout_lines
|
||||
|
||||
- name: Imposm - Optimze database
|
||||
command: imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --connection=postgis://osm:osm@localhost:5432/osm --optimize
|
||||
args:
|
||||
chdir: /srv/osm/imposm
|
||||
when: imposm_pbf_list.stdout_lines
|
||||
|
||||
- name: Imposm - Switch new data to production
|
||||
command: imposm --mapping-file=/srv/osm/basemaps/imposm-mapping.py --proj=EPSG:3857 --connection=postgis://osm:osm@localhost:5432/osm --deploy-production-tables
|
||||
args:
|
||||
chdir: /srv/osm/imposm
|
||||
when: imposm_pbf_list.stdout_lines
|
||||
|
75
roles/mapserver/tasks/50_mapcache-and-apache.yml
Normal file
75
roles/mapserver/tasks/50_mapcache-and-apache.yml
Normal file
|
@ -0,0 +1,75 @@
|
|||
---
|
||||
|
||||
|
||||
# MapCache
|
||||
- name: Configure MapCache
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: /srv/osm/mapcache/mapcache.xml
|
||||
backup: no
|
||||
with_first_found:
|
||||
- "mapcache/mapcache.xml.{{ ansible_fqdn }}.j2"
|
||||
- "mapcache/mapcache.xml.{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.j2"
|
||||
- "mapcache/mapcache.xml.{{ ansible_distribution }}.j2"
|
||||
- "mapcache/mapcache.xml.j2"
|
||||
notify:
|
||||
- handlerRestartApache
|
||||
|
||||
|
||||
# Apache customizations
|
||||
- name: Apache - Activate CGI module
|
||||
apache2_module:
|
||||
state: present
|
||||
name: cgid
|
||||
notify:
|
||||
- handlerRestartApache
|
||||
|
||||
# Kinda paranoiac but I prefer the CGI not being freely accessible
|
||||
- name: Apache - Restrict access to CGI
|
||||
lineinfile:
|
||||
path: /etc/apache2/conf-available/serve-cgi-bin.conf
|
||||
regexp: '^(\s+)Require '
|
||||
line: '\1Require local'
|
||||
backrefs: yes
|
||||
notify:
|
||||
- handlerRestartApache
|
||||
|
||||
# We gather some extra data for the vhost template
|
||||
- name: Apache - Set a fact about whether SSL is enabled or not - 1
|
||||
apache2_module:
|
||||
state: present
|
||||
name: ssl
|
||||
check_mode: yes
|
||||
register: tmp
|
||||
- name: Apache - Set a fact about whether SSL is enabled or not - 2
|
||||
set_fact:
|
||||
apache_module_ssl_enabled: "{{ not tmp.changed }}"
|
||||
|
||||
- name: Apache - Set up vhost
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ mapcache_vhost_filename }}"
|
||||
backup: no
|
||||
with_first_found:
|
||||
- "apache2/vhost.{{ ansible_fqdn }}.j2"
|
||||
- "apache2/vhost.{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.j2"
|
||||
- "apache2/vhost.{{ ansible_distribution }}.j2"
|
||||
- "apache2/vhost.j2"
|
||||
notify:
|
||||
- handlerRestartApache
|
||||
|
||||
# We try not to generate a 'changed' when using a2ensite, so we check beforehand.
|
||||
- name: Apache - Check if vhost is enabled
|
||||
command: find -L /etc/apache2/sites-enabled/ -samefile {{ mapcache_vhost_filename | quote }}
|
||||
register: tmp
|
||||
changed_when: False
|
||||
check_mode: no
|
||||
- name: Apache - Enable vhost
|
||||
command: a2ensite {{ mapcache_vhost_filename | basename | quote }}
|
||||
when: not tmp.stdout
|
||||
notify:
|
||||
- handlerRestartApache
|
||||
|
||||
- name: Apache - Check config
|
||||
command: apache2ctl configtest
|
||||
changed_when: False
|
38
roles/mapserver/tasks/main.yml
Normal file
38
roles/mapserver/tasks/main.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
|
||||
- name: Gather os specific variables
|
||||
block:
|
||||
- include_vars: "{{ item }}"
|
||||
with_first_found: # Files are in 'vars/' subdirectory and contain a one level dictionary 'var: value'
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
#- "defaults.yml" # No defaults for this role at the moment.
|
||||
rescue:
|
||||
- fail:
|
||||
msg: "Unexpected OS/Distribution. Create and fill vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
|
||||
# Dedicated directories
|
||||
- name: Imposm dedicated directory
|
||||
file:
|
||||
path: /srv/osm/imposm
|
||||
state: directory
|
||||
- name: MapCache dedicated directory
|
||||
file:
|
||||
path: /srv/osm/mapcache
|
||||
state: directory
|
||||
|
||||
# Packages installation
|
||||
- import_tasks: 10_package-install.yml
|
||||
|
||||
# Database creation
|
||||
- import_tasks: 20_database-creation.yml
|
||||
|
||||
# Retrieve the OSM basemaps
|
||||
- import_tasks: 30_basemaps.yml
|
||||
|
||||
# Import with imposm
|
||||
- import_tasks: 40_imposm.yml
|
||||
|
||||
# Mapcache and Apache
|
||||
- import_tasks: 50_mapcache-and-apache.yml
|
32
roles/mapserver/templates/apache2/vhost.j2
Normal file
32
roles/mapserver/templates/apache2/vhost.j2
Normal file
|
@ -0,0 +1,32 @@
|
|||
<VirtualHost *:80>
|
||||
# The ServerName directive sets the request scheme, hostname and port that
|
||||
# the server uses to identify itself. This is used when creating
|
||||
# redirection URLs. In the context of virtual hosts, the ServerName
|
||||
# specifies what hostname must appear in the request's Host: header to
|
||||
# match this virtual host. For the default virtual host (this file) this
|
||||
# value is not decisive as it is used as a last resort host regardless.
|
||||
# However, you must set it for any further virtual host explicitly.
|
||||
#ServerName www.example.com
|
||||
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
|
||||
# error, crit, alert, emerg.
|
||||
# It is also possible to configure the loglevel for particular
|
||||
# modules, e.g.
|
||||
#LogLevel info ssl:warn
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
|
||||
# For most configuration files from conf-available/, which are
|
||||
# enabled or disabled at a global level, it is possible to
|
||||
# include a line for only one particular virtual host. For example the
|
||||
# following line enables the CGI configuration for this host only
|
||||
# after it has been globally disabled with "a2disconf".
|
||||
#Include conf-available/serve-cgi-bin.conf
|
||||
MapCacheAlias /mapcache "/srv/osm/mapcache/mapcache.xml"
|
||||
</VirtualHost>
|
||||
|
||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
127
roles/mapserver/templates/basemaps/Makefile.j2
Normal file
127
roles/mapserver/templates/basemaps/Makefile.j2
Normal file
|
@ -0,0 +1,127 @@
|
|||
UNAME := $(shell uname)
|
||||
|
||||
ifeq ($(UNAME), Darwin)
|
||||
SED=sed -i ""
|
||||
else
|
||||
SED=sed -i
|
||||
endif
|
||||
|
||||
CPP=gcc -E -x c
|
||||
#if the preprocessor fails for some reason, try replacing this with "cpp" on linux, or "cpp-4.2" on darwin (not available starting with mountain lion)
|
||||
|
||||
|
||||
OSM_PREFIX?=osm_
|
||||
OSM_NAME_COLUMN?=name
|
||||
#OSM_SRID?=4326
|
||||
#OSM_UNITS?=dd
|
||||
#OSM_EXTENT?=-180 -90 180 90
|
||||
OSM_SRID?=3857
|
||||
OSM_UNITS?=meters
|
||||
OSM_DB_CONNECTION?=host=localhost dbname=osm user=osm password=osm port=5432
|
||||
OSM_EXTENT?=-20000000 -20000000 20000000 20000000
|
||||
OSM_FORCE_POSTGIS_EXTENT?=0
|
||||
OSM_WMS_SRS?=EPSG:900913 EPSG:4326 EPSG:3857 EPSG:2154 EPSG:310642901 EPSG:4171 EPSG:310024802 EPSG:310915814 EPSG:310486805 EPSG:310702807 EPSG:310700806 EPSG:310547809 EPSG:310706808 EPSG:310642810 EPSG:310642801 EPSG:310642812 EPSG:310032811 EPSG:310642813 EPSG:2986
|
||||
DEBUG?=1
|
||||
LAYERDEBUG?=1
|
||||
PROJ_LIB?=`pwd`
|
||||
STYLE?={{ basemaps_style }}
|
||||
#can also use google or bing
|
||||
|
||||
template=osmbase.map
|
||||
|
||||
includes=land.map landusage.map borders.map highways.map places.map \
|
||||
generated/$(STYLE)style.msinc \
|
||||
generated/$(STYLE)level0.msinc generated/$(STYLE)level1.msinc generated/$(STYLE)level2.msinc generated/$(STYLE)level3.msinc \
|
||||
generated/$(STYLE)level4.msinc generated/$(STYLE)level5.msinc generated/$(STYLE)level6.msinc generated/$(STYLE)level7.msinc \
|
||||
generated/$(STYLE)level8.msinc generated/$(STYLE)level9.msinc generated/$(STYLE)level10.msinc generated/$(STYLE)level11.msinc \
|
||||
generated/$(STYLE)level12.msinc generated/$(STYLE)level13.msinc generated/$(STYLE)level14.msinc generated/$(STYLE)level15.msinc \
|
||||
generated/$(STYLE)level16.msinc generated/$(STYLE)level17.msinc generated/$(STYLE)level18.msinc
|
||||
|
||||
|
||||
|
||||
mapfile=osm-$(STYLE).map
|
||||
|
||||
all:$(mapfile) boundaries.sql
|
||||
|
||||
generated/$(STYLE)style.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -g > $@
|
||||
|
||||
generated/$(STYLE)level0.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 0 > $@
|
||||
|
||||
generated/$(STYLE)level1.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 1 > $@
|
||||
|
||||
generated/$(STYLE)level2.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 2 > $@
|
||||
|
||||
generated/$(STYLE)level3.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 3 > $@
|
||||
|
||||
generated/$(STYLE)level4.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 4 > $@
|
||||
|
||||
generated/$(STYLE)level5.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 5 > $@
|
||||
|
||||
generated/$(STYLE)level6.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 6 > $@
|
||||
|
||||
generated/$(STYLE)level7.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 7 > $@
|
||||
|
||||
generated/$(STYLE)level8.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 8 > $@
|
||||
|
||||
generated/$(STYLE)level9.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 9 > $@
|
||||
|
||||
generated/$(STYLE)level10.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 10 > $@
|
||||
|
||||
generated/$(STYLE)level11.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 11 > $@
|
||||
|
||||
generated/$(STYLE)level12.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 12 > $@
|
||||
|
||||
generated/$(STYLE)level13.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 13 > $@
|
||||
|
||||
generated/$(STYLE)level14.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 14 > $@
|
||||
|
||||
generated/$(STYLE)level15.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 15 > $@
|
||||
|
||||
generated/$(STYLE)level16.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 16 > $@
|
||||
|
||||
generated/$(STYLE)level17.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 17 > $@
|
||||
|
||||
generated/$(STYLE)level18.msinc: generate_style.py
|
||||
python generate_style.py -s $(STYLE) -l 18 > $@
|
||||
|
||||
$(mapfile):$(template) $(includes)
|
||||
$(CPP) -D_debug=$(DEBUG) -D_layerdebug=$(LAYERDEBUG) -DOSM_PREFIX=$(OSM_PREFIX) -DOSM_SRID=$(OSM_SRID) -DOSM_FORCE_POSTGIS_EXTENT=$(OSM_FORCE_POSTGIS_EXTENT) -P -o $(mapfile) $(template) -DTHEME=$(STYLE) -D_proj_lib=\"$(PROJ_LIB)\" -Igenerated
|
||||
$(SED) 's/##.*$$//g' $(mapfile)
|
||||
$(SED) '/^ *$$/d' $(mapfile)
|
||||
$(SED) -e 's/OSM_PREFIX_/$(OSM_PREFIX)/g' $(mapfile)
|
||||
$(SED) -e 's/OSM_SRID/$(OSM_SRID)/g' $(mapfile)
|
||||
$(SED) -e 's/OSM_UNITS/$(OSM_UNITS)/g' $(mapfile)
|
||||
$(SED) -e 's/OSM_EXTENT/$(OSM_EXTENT)/g' $(mapfile)
|
||||
$(SED) -e 's/OSM_WMS_SRS/$(OSM_WMS_SRS)/g' $(mapfile)
|
||||
$(SED) -e 's/OSM_NAME_COLUMN/$(OSM_NAME_COLUMN)/g' $(mapfile)
|
||||
$(SED) -e 's/OSM_DB_CONNECTION/$(OSM_DB_CONNECTION)/g' $(mapfile)
|
||||
|
||||
boundaries.sql: boundaries.sql.in
|
||||
cp -f $< $@
|
||||
$(SED) -e 's/OSM_PREFIX_/$(OSM_PREFIX)/g' $@
|
||||
|
||||
clean:
|
||||
rm -f generated/*
|
||||
|
||||
.PHONY: data
|
||||
data:
|
||||
cd data; $(MAKE) $(MFLAGS)
|
62
roles/mapserver/templates/mapcache/mapcache.xml.Debian-10.j2
Normal file
62
roles/mapserver/templates/mapcache/mapcache.xml.Debian-10.j2
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- see the accompanying mapcache.xml.sample for a fully commented configuration file -->
|
||||
|
||||
<mapcache>
|
||||
<cache name="disk" type="disk">
|
||||
<base>/tmp</base>
|
||||
<symlink_blank/>
|
||||
</cache>
|
||||
<cache name="sqlite" type="sqlite3">
|
||||
<dbfile>/tmp/{tileset}-{z}-{grid}.db</dbfile>
|
||||
<detect_blank/>
|
||||
</cache>
|
||||
|
||||
<source name="vmap0" type="wms">
|
||||
<getmap>
|
||||
<params>
|
||||
<FORMAT>image/png</FORMAT>
|
||||
<LAYERS>default</LAYERS>
|
||||
<MAP>/srv/osm/basemaps/osm-{{ basemaps_style }}.map</MAP>
|
||||
</params>
|
||||
</getmap>
|
||||
|
||||
<http>
|
||||
<url>http://localhost/cgi-bin/mapserv?</url>
|
||||
</http>
|
||||
</source>
|
||||
|
||||
<tileset name="test">
|
||||
<source>vmap0</source>
|
||||
<cache>sqlite</cache>
|
||||
<grid>WGS84</grid>
|
||||
<grid>GoogleMapsCompatible</grid>
|
||||
<format>PNG</format>
|
||||
<metatile>5 5</metatile>
|
||||
<metabuffer>10</metabuffer>
|
||||
<expires>3600</expires>
|
||||
</tileset>
|
||||
|
||||
<default_format>JPEG</default_format>
|
||||
|
||||
<service type="wms" enabled="true">
|
||||
<full_wms>assemble</full_wms>
|
||||
<resample_mode>bilinear</resample_mode>
|
||||
<format>JPEG</format>
|
||||
<maxsize>4096</maxsize>
|
||||
</service>
|
||||
<service type="wmts" enabled="true"/>
|
||||
<service type="tms" enabled="true"/>
|
||||
<service type="kml" enabled="true"/>
|
||||
<service type="gmaps" enabled="true"/>
|
||||
<service type="ve" enabled="true"/>
|
||||
<service type="mapguide" enabled="true"/>
|
||||
<service type="demo" enabled="true"/>
|
||||
|
||||
<errors>report</errors>
|
||||
<locker type="disk">
|
||||
<directory>/tmp</directory>
|
||||
<timeout>300</timeout>
|
||||
</locker>
|
||||
|
||||
</mapcache>
|
16
roles/mapserver/vars/Debian-10.yml
Normal file
16
roles/mapserver/vars/Debian-10.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
|
||||
# basemaps needs make unzip wget git
|
||||
packages_list:
|
||||
- apache2
|
||||
- cgi-mapserver
|
||||
- git
|
||||
- imposm
|
||||
- libapache2-mod-mapcache
|
||||
- make
|
||||
- mapserver-bin
|
||||
- postgis
|
||||
- unzip
|
||||
- wget
|
||||
|
||||
mapcache_vhost_filename: /etc/apache2/sites-available/000-default.conf
|
6
site.yml
Normal file
6
site.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
|
||||
- name: "Role for OSM/MapServer/Postgis installation and management"
|
||||
hosts: all
|
||||
roles:
|
||||
- mapserver
|
Loading…
Add table
Add a link
Reference in a new issue