Skip to content

Commit

Permalink
ansible config for provisioning of the production server
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenwh committed Jul 12, 2019
1 parent 945de6a commit ae84d8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 89 deletions.
4 changes: 0 additions & 4 deletions provisioning/conda_env_requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ dependencies:
- ipython
- ipdb
- thredds_crawler
- cartopy
- basemap-data-hires
- folium
- jupyter
87 changes: 5 additions & 82 deletions provisioning/roles/openwind/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,58 +49,21 @@
# path: "{{ conda_dir }}/envs/{{ env_name }}/etc/conda/deactivate.d/env_vars.sh"
# line: "unset PROJ_LIB={{ conda_dir }}/envs/{{ env_name }}/share/proj"

- name: openwind | create shell script to run jupyter notebook
file:
path: /home/vagrant/run_jupyter.sh
state: touch
mode: u=rwx,g=r,o=r

- name: openwind | Set header in run_jupyter.sh script
lineinfile:
path: /home/vagrant/run_jupyter.sh
insertbefore: BOF
line: "#!/bin/bash"

- name: openwind | Wait a little before activating env and starting jupyter
lineinfile:
path: /home/vagrant/run_jupyter.sh
line: sleep 60

- name: openwind | Line to activate virtual env in shell script
lineinfile:
path: /home/vagrant/run_jupyter.sh
line: "source {{ conda_dir }}/bin/activate {{ env_name }}"

- name: openwind | Line to start jupyter in shell script
lineinfile:
path: /home/vagrant/run_jupyter.sh
line: "{{ conda_dir }}/envs/{{ env_name }}/bin/jupyter-notebook --ip=0.0.0.0 --no-browser --notebook-dir=/vagrant/notebooks/ --NotebookApp.token=vagrant"

- name: openwind | Set cron shell to bash
cron:
name: SHELL
env: yes
job: /bin/bash

- name: openwind | Add Jupyter Notebook to crontab
- name: openwind | Set up daily processing
cron:
name: "Jupyter Notebook"
special_time: reboot
job: "/home/vagrant/run_jupyter.sh"

- name: openwind | Check if Jupyter is running
shell: ps aux | grep jupyter | grep -v grep
ignore_errors: yes
changed_when: false
register: jupyter_status
name: "Daily processing"
special_time: daily
job: "{{ project_home }}/daily_sync.sh"

- name: openwind | Launch Jupyter Notebook
shell: "nohup /home/vagrant/run_jupyter.sh > /dev/null 2>&1 &"
when: jupyter_status.rc != 0

- name: openwind | Create shell script for daily data sync and wind processing
file:
path: /home/vagrant/daily_sync.sh
path: "{{ project_home }}/daily_sync.sh"
state: touch
mode: u=rwx,g=r,o=r

Expand All @@ -126,43 +89,3 @@
# Process S1 wind
{{ conda_dir }}/envs/{{ env_name }}/bin/python {{ project_home }}/{{ project_name }}/manage.py process_sentinel1_wind --date `date -d "yesterday 00:00" '+%Y-%m-%d'`
# shell: "source activate {{ env_name }}; nohup {{ conda_dir }}/envs/{{ env_name }}/bin/jupyter-notebook --ip=0.0.0.0 --no-browser --notebook-dir=/vagrant/notebooks/ --NotebookApp.token=vagrant > /dev/null 2>&1 &"

#- name: Nansat Setup Python | Check if numpy is imported
# shell: "nosetests test_import.py"
# args:
# chdir: "{{ shared_dir }}"

#- name: openwind | Update/checkout Nansat
# git: repo=https://github.com/nansencenter/nansat
# dest="{{ dev_sources_dir }}/nansat/"
# version="{{ nansat_version }}"
# update=yes
# register: git_nansat
# tags:
# - update-nansat
# ignore_errors: no
#
#- name: openwind | Clean Nansat (always run to keep the pixel functions updated)
# shell: 'python setup.py clean --all'
# args:
# chdir: '{{ dev_sources_dir }}/nansat'
# tags:
# - update-nansat
#
#- name: openwind | Install Nansat (always run to keep the pixel functions updated)
# shell: 'python setup.py build_ext --inplace'
# args:
# chdir: '{{ dev_sources_dir }}/nansat'
# tags:
# - update-nansat
#
#- name: openwind | Create link from Python dist-packages to nansat
# file: path='{{ python_dist_packages }}/nansat'
# src='{{ dev_sources_dir }}/nansat/nansat'
# state=link
# force=yes
#
#- name: nansat | Create link from Python dist-packages to nansat_integration_tests
#
7 changes: 4 additions & 3 deletions provisioning/site.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- hosts: openwind
vars:
project_home: '/vagrant/lib'
project_name: 'project'
project_home: '/home/sarvind'
project_name: 'geospaas_project'
env_name: 'py3openwind'
conda_dir: '/home/vagrant/anaconda'
conda_dir: "{{ project_home }}/anaconda"
conda_env_update_if_present: True

roles:
Expand All @@ -13,6 +13,7 @@
django_project_name: '{{ project_name }}'
django_conda_dir: '{{ conda_dir }}'
django_env_name: '{{ env_name }}'
django_products_root: '/Data/sarvind'
django_apps:
- geospaas.vocabularies
- geospaas.catalog
Expand Down

0 comments on commit ae84d8c

Please sign in to comment.