---
- name: Create path for maps
  file: path=/var/osm/ state=directory owner=root group=root mode=0644
  tags:
    - osm

- name: Download OSM map from Geofabrik
  sudo: yes
  shell: wget http://download.geofabrik.de/australia-oceania/new-zealand-latest.osm.pbf
  args:
    chdir: /var/osm/
    creates: /var/osm/new-zealand-latest.osm.pbf
  tags:
    - osm

- name: Read data using imposm
  sudo: yes
  shell: imposm --proj=EPSG:3857 --read new-zealand-latest.osm.pbf && touch /var/osm/imposm_coords.cache
  args:
    creates: /var/osm/imposm_coords.cache
    chdir: /var/osm/
  tags:
    - osm

- name: Writes data using imposm
  sudo: yes
  shell: imposm --proj=EPSG:3857 --write --connection postgis://osm:osm@localhost/osm new-zealand-latest.osm.pbf && touch /var/osm/write_ansible_flag
  args:
    creates: /var/osm/write_ansible_flag
    chdir: /var/osm/
  tags:
    - osm

- name: Deploy and optimise tables
  sudo: yes
  shell: imposm --optimize -d osm && touch /var/osm/optimise_ansible_flag
  args:
    creates: /var/osm/optimise_ansible_flag
    chdir: /var/osm/
  tags:
    - osm
---
- name: Create path for maps
  file: path=/var/osm/ state=directory owner=root group=root mode=0644
  tags:
    - osm

- name: Download OSM map from Geofabrik
  sudo: yes
  shell: wget http://download.geofabrik.de/australia-oceania/new-zealand-latest.osm.pbf
  args:
    chdir: /var/osm/
    creates: /var/osm/new-zealand-latest.osm.pbf
  tags:
    - osm

- name: Read data using imposm
  sudo: yes
  shell: imposm --proj=EPSG:3857 --read new-zealand-latest.osm.pbf
  args:
    creates: /var/osm/imposm_coords.cache
    chdir: /var/osm/
  tags:
    - osm

- name: Writes data using imposm
  sudo: yes
  shell: imposm --proj=EPSG:3857 --write --connection postgis://osm:osm@localhost/osm new-zealand-latest.osm.pbf && touch /var/osm/write_ansible_flag
  args:
    creates: /var/osm/write_ansible_flag
    chdir: /var/osm/
  tags:
    - osm

- name: Deploy and optimise tables
  sudo: yes
  shell: imposm --optimize -d osm && touch /var/osm/optimise_ansible_flag
  args:
    creates: /var/osm/optimise_ansible_flag
    chdir: /var/osm/
  tags:
    - osm
Remove touch for imposm_coords.cache since it's created by imposm
Remove touch for imposm_coords.cache since it's created by imposm
