50 lines
1.8 KiB
YAML
50 lines
1.8 KiB
YAML
|
---
|
||
|
|
||
|
# 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
|
||
|
|