Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magrit playbook: Cartography Teaching+Learning #1579

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions roles/9-local-addons/tasks/main.yml
Expand Up @@ -21,6 +21,12 @@
when: minetest_install
tags: minetest

- name: MAGRIT
include_role:
name: magrit
when: magrit_install
tags: magrit

- name: Recording STAGE 9 HAS COMPLETED ====================
lineinfile:
dest: "{{ iiab_env_file }}"
Expand Down
5 changes: 5 additions & 0 deletions roles/magrit/defaults/main.yml
@@ -0,0 +1,5 @@
magrit_port: 9999
magrit_dir: /opt/iiab/magrit
magrit_venv: /opt/iiab/magrit/venv
magrit_install: False
magrit_enabled: False
102 changes: 102 additions & 0 deletions roles/magrit/tasks/main.yml
@@ -0,0 +1,102 @@
- name: Install packages reqpured for magrit thematic mapping https://github.com/riatelab/magrit
package:
name:
- libpython3.5-dev
- python3.5
- python3.5-dev
- python3-pip
- libopenblas-dev
- libopenblas-base
- libfreetype6-dev
- libfreetype6
- libproj-dev
- libspatialindex-dev
- libv8-3.14-dev
- libffi-dev
- node-gyp
- libuv1-dev
- libxslt1-dev
- libxml2
- libxml2-dev
- libkml-dev
- libgeos-dev
- redis-server
- libatlas-base-dev
state: present
when: internet_available and is_rpi
tags:
- download

- name: Check if our package is already downloaded
stat:
path: '{{ downloads_dir }}/gdal_2.2.3-1_armhf.deb'
register: p

- name: Download our compiled version of Geospatial Data Abstraction lIbrary (GDAL)
get_url:
url: '{{ iiab_download_url }}/gdal_2.2.3-1_armhf.deb'
dest: '{{ downloads_dir }}'
when: p.stat.isdir is defined and p.stat.isdir and internet_available and is_rpi

- name: Install GDAL
shell: "apt-get install {{ downloads_dir }}/gdal_2.2.3-1_armhf.deb"
args:
warn: false
when: internet_available and is_rpi

- name: Tell the loader where to find the libgdal library
shell: ldconfig /usr/local/lib
when: internet_available and is_rpi

- name: Clone magrit repo
git:
repo: https://github.com/riatelab/magrit
dest: "{{ magrit_venv }}"
version: master
update: yes
force: yes
when: internet_available and is_rpi and magrit_install

- name: Install magrit with dependencies using pip, into virtualenv (debuntu)
pip:
name:
- numpy
- ujson
- docopt
- pandas
virtualenv: "{{ magrit_venv }}"
virtualenv_python: python3.5
when: internet_available and is_rpi

- name: Install the magrit requirements
pip:
requirements: '{{ magrit_venv }}/requirements/dev.txt'
virtualenv: "{{ magrit_venv }}"

- name: Edit the python environment spec
lineinfile:
path: '{{ magrit_venv }}/magrit_app/app.py'
regexp: '^#!/usr/bin/env.*'
line: '#!/usr/bin/env python3.5'

- name: Compile the python helper stubs
shell: "{{ magrit_venv }}/bin/cythonize -i -b {{ magrit_venv }}/magrit_app/*.pyx"

- name: Put systemd service file
template:
src: magrit.service.j2
dest: /etc/systemd/system/magrit.service

- name: Enable systemd for magrit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 83-95 look incomplete.

Use https://github.com/iiab/iiab/blob/master/roles/nodered/tasks/main.yml#L202-L216 as a model if poss?

systemd:
enabled: True
started: True
when:
magrit_enabled: True

- name: Disable systemd for magrit
systemd:
enabled: False
started: False
when:
magrit_enabled == False
11 changes: 11 additions & 0 deletions roles/magrit/templates/magrit.service.j2
@@ -0,0 +1,11 @@
[Unit]
Description=Magrit
After=network-online.target

[Service]
Type=oneshot
ExecStart={{ magrit_venv }}/bin/python3.5 -m /{{ magrit_venv }}/magrit_app/app,py --port {{ magrit_port }} --address {{ lan_ip }}

[Install]
WantedBy=multi-user.target