Commit 1e502f54 authored by eric pellegrini's avatar eric pellegrini

added role for setting up jupyterhub kernels

parent 2dd0e656
......@@ -27,5 +27,8 @@
- name: setup jupyterhub
import_playbook: "{{ playbook_dir | dirname }}/plays/setup_jupyterhub.yml"
- name: setup juyterhub kernels
import_playbook: "{{ playbook_dir | dirname }}/plays/setup_jupyterhub_kernels.yml"
- name: setup nginx server
import_playbook: "{{ playbook_dir | dirname }}/plays/setup_nginx.yml"
---
- hosts: jhub_servers
remote_user: "{{ cluster_users.1.name }}"
environment: "{{ proxy_settings }}"
tasks:
- import_role:
name: roles/jupyterhub-kernels
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
# defaults file for roles/jupyterhub-kernels
\ No newline at end of file
name: bash
channels:
- conda-forge
- defaults
dependencies:
- pip
- pip:
- bash_kernel
- jupyter
name: cpp
channels:
- conda-forge
- anaconda
- defaults
dependencies:
- jupyter
- git
- eigen
- boost
- fftw
- hdf5
- xeus-cling
- openmpi
name: data-analysis
channels:
- rdkit
- conda-forge
- anaconda
- defaults
dependencies:
- python
- ipython
- ipykernel
- numpy
- matplotlib
- h5py
- scipy
- pandas
- scikit-learn
- sympy
- numexpr
- numba
- tensorflow
- biopython
- rdkit
name: data-reduction
channels:
- mantid/label/nightly
- mantid
- conda-forge
- defaults
dependencies:
- pocl
- python
- ipython
- ipykernel
- numpy
- matplotlib
- h5py
- scipy
- pandas
- scikit-learn
- sympy
- numexpr
- numba
- sasview
- mantid-framework
name: fortran
channels:
- conda-forge
- defaults
dependencies:
- imagemagick
- git
- pip
- pip:
- jupyter-fortran-kernel
- jupyter
- gfortran_linux-64
- openmpi
name: julia
channels:
- conda-forge
- defaults
dependencies:
- python
- jupyter
name: mdanse
channels:
- conda-forge
- anaconda
- defaults
dependencies:
- git
- gcc_linux-64
- gxx_linux-64
- libgfortran
- libnetcdf
- cython
- python=2.7
- ipython
- ipykernel
- path.py
- sphinx
- setuptools
- numpy
- matplotlib
- wxpython
- pip
- pip:
- pyro
name: octave
channels:
- bioconda/label/cf201901
- conda-forge/label/cf201901
- anaconda
- defaults
dependencies:
- jupyter
- gnuplot
- octave
- octave_kernel
- texinfo
name: r
channels:
- r
- defaults
dependencies:
- jupyter
- r-irkernel
{
"argv": [
"python3",
"-m",
"jupyter_fortran_kernel",
"-f",
"{connection_file}"
],
"display_name": "Fortran",
"language": "Fortran"
}
---
# handlers file for roles/jupyterhub-kernels
\ No newline at end of file
galaxy_info:
author: your name
description: your description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.4
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
\ No newline at end of file
---
# tasks file for roles/jupyterhub-kernels
- block:
- include: setup-bash-environment.yml
- include: setup-cpp-environment.yml
- include: setup-data-analysis-environment.yml
- include: setup-data-reduction-environment.yml
- include: setup-fortran-environment.yml
- include: setup-julia-environment.yml
- include: setup-mdanse-environment.yml
- include: setup-octave-environment.yml
- include: setup-r-environment.yml
vars:
conda_envs_dir: "{{ ansible_env.HOME }}/miniconda3/envs"
conda_exe: "{{ ansible_env.HOME }}/miniconda3/bin/conda"
conda_root: "{{ ansible_env.HOME }}/miniconda3"
- name: copy the conda environment file for bash
copy:
src: environment_bash.yml
dest: /tmp
- name: setup the conda environment for bash
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_bash.yml --force
conda activate bash
jupyter kernelspec remove -f python3
conda activate bash
python -m bash_kernel.install
conda deactivate
args:
executable: /bin/bash
- name: copy the bash kernel from .local to proper location
copy:
src: "{{ jupyter_admin_home }}/.local/share/jupyter/kernels/bash"
dest: "{{ conda_envs_dir }}/bash/share/jupyter/kernels/"
remote_src: yes
- name: remove the bash kernel located in .local
file:
path: "{{ ansible_env.HOME }}/.local/share/jupyter/kernels/bash"
state: absent
- name: copy the bash logo
copy:
src: "bash/{{ item }}"
dest: "{{ conda_envs_dir }}/bash/share/jupyter/kernels/bash/"
loop:
- logo-32x32.png
- logo-64x64.png
- name: copy the conda environment file for cpp
copy:
src: environment_cpp.yml
dest: /tmp
- name: setup the conda environment for cpp
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_cpp.yml --force
conda activate cpp
jupyter kernelspec remove -f python3
jupyter kernelspec remove -f xcpp11
jupyter kernelspec remove -f xcpp14
conda deactivate
args:
executable: /bin/bash
- name: copy the conda environment file for data analysis
copy:
src: environment_data_analysis.yml
dest: /tmp
- name: setup the conda environment for data analysis
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_data_analysis.yml --force
args:
executable: /bin/bash
- name: copy the conda environment file for data reduction
copy:
src: environment_data_reduction.yml
dest: /tmp
- name: setup the conda environment for data reduction
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_data_reduction.yml --force
args:
executable: /bin/bash
- name: copy the bash logo
copy:
src: "data-reduction/{{ item }}"
dest: "{{ conda_envs_dir }}/data-reduction/share/jupyter/kernels/python3/"
loop:
- logo-32x32.png
- logo-64x64.png
- name: copy the conda environment file for fortran
copy:
src: environment_fortran.yml
dest: /tmp
- name: setup the conda environment for fortran
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_fortran.yml --force
conda activate fortran
jupyter kernelspec remove -f python3
conda deactivate
args:
executable: /bin/bash
- name: create fortran kernel directory
file:
path: "{{ conda_envs_dir }}/fortran/share/jupyter/kernels/fortran"
state: directory
- name: copy fortran kernel file
copy:
src: fortran-kernel.json
dest: "{{ conda_envs_dir }}/fortran/share/jupyter/kernels/fortran/kernel.json"
- name: create a symbolic to gfortran
file:
src: "{{ conda_envs_dir }}/fortran/bin/x86_64-conda_cos6-linux-gnu-gfortran"
dest: "{{ conda_envs_dir }}/fortran/bin/gfortran"
state: link
- name: copy the bash logo
copy:
src: "data-reduction/{{ item }}"
dest: "{{ conda_envs_dir }}/fortran/share/jupyter/kernels/fortran/"
loop:
- logo-32x32.png
- logo-64x64.png
- name: copy the conda environment file for julia
copy:
src: environment_julia.yml
dest: /tmp
- name: setup the conda environment for julia
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_julia.yml --force
conda activate julia
jupyter kernelspec remove -f python3
conda deactivate
args:
executable: /bin/bash
- name: fetch the latest julia package
get_url:
url: https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.4-linux-x86_64.tar.gz
dest: "{{ jupyter_admin_home }}/julia.tar.gz"
- name: create the directory for julia installation
file:
path: "{{ conda_envs_dir }}/julia/opt"
state: directory
- name: unarchive the julia installer
unarchive:
src: "{{ jupyter_admin_home }}/julia.tar.gz"
dest: "{{ conda_envs_dir }}/julia/opt"
remote_src: yes
keep_newer: yes
- name: remove julia installer archive
file:
path: "{{ jupyter_admin_home }}/julia.tar.gz"
state: absent
- name: install julia kernel and extra plotting packages
shell: |
"{{ conda_envs_dir }}"/julia/opt/julia-1.0.4/bin/julia -e 'using Pkg ; Pkg.add("PyCall") ; Pkg.add("Conda") ; Pkg.add("IJulia") ; Pkg.add("PyPlot") ; Pkg.add("Plots")'
environment:
PYTHON: "{{ conda_envs_dir }}/julia/bin/python"
- name: copy the julia kernel from .local to proper location
copy:
src: "{{ ansible_env.HOME }}/.local/share/jupyter/kernels/julia-1.0"
dest: "{{ conda_envs_dir }}/julia/share/jupyter/kernels/"
remote_src: yes
- name: remove the julia kernel located in .local
file:
path: "{{ ansible_env.HOME }}/.local/share/jupyter/kernels/julia-1.0"
state: absent
- name: remove the ~/.julia directory
file:
path: "{{ ansible_env.HOME }}/.julia"
state: absent
- name: copy the conda environment file for MDANSE
copy:
src: environment_mdanse.yml
dest: /tmp
- name: setup the conda environment for MDANSE
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_mdanse.yml --force
conda activate mdanse
jupyter kernelspec remove -f python3
conda deactivate
args:
executable: /bin/bash
- name: create a symbolic to gcc
file:
src: "{{ conda_envs_dir }}/mdanse/bin/x86_64-conda_cos6-linux-gnu-gcc"
dest: "{{ conda_envs_dir }}/mdanse/bin/gcc"
state: link
- name: create a symbolic to g++
file:
src: "{{ conda_envs_dir }}/mdanse/bin/x86_64-conda_cos6-linux-gnu-g++"
dest: "{{ conda_envs_dir }}/mdanse/bin/g++"
state: link
- name: clone ScientificPython repository
git:
repo: https://code.ill.fr/scientific-software/scientific-python.git
dest: "{{ jupyter_admin_home }}/git/scientific-python"
version: HEAD
- name: install ScientificPython package
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda activate mdanse
python2 setup.py build --netcdf_prefix="{{ conda_envs_dir }}/mdanse/"
python2 setup.py install
args:
chdir: "{{ jupyter_admin_home }}/git/scientific-python"
executable: /bin/bash
- name: copy netcdf header into ScientificPython include directory
copy:
src: "{{ conda_envs_dir }}/mdanse/include/netcdf.h"
dest: "{{ conda_envs_dir }}/mdanse/include/python2.7/Scientific/."
remote_src: yes
- name: remove ScientificPython sources
file:
path: "{{ ansible_env.HOME }}/git/scientific-python"
state: absent
- name: clone MMTK repository
git:
repo: https://code.ill.fr/scientific-software/mmtk.git
dest: "{{ jupyter_admin_home }}/git/mmtk"
version: HEAD
- name: install MMTK package
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda activate mdanse
python2 setup.py build
python2 setup.py install
args:
chdir: "{{ jupyter_admin_home }}/git/mmtk"
executable: /bin/bash
- name: remove MMTK sources
file:
path: "{{ jupyter_admin_home }}/git/mmtk"
state: absent
- name: clone MDANSE repository
git:
repo: https://code.ill.fr/scientific-software/mdanse.git
dest: "{{ ansible_env.HOME }}/git/mdanse"
version: HEAD
- name: install MDANSE package
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda activate mdanse
python2 setup.py build
python2 setup.py install
args:
chdir: "{{ ansible_env.HOME }}/git/mdanse"
executable: /bin/bash
- name: remove MDANSE sources
file:
path: "{{ jupyter_admin_home }}/git/mdanse"
state: absent
- name: copy the bash logo
copy:
src: "bash/{{ item }}"
dest: "{{ conda_envs_dir }}/mdanse/share/jupyter/kernels/python2/"
loop:
- logo-32x32.png
- logo-64x64.png
- name: copy the conda environment file for octave
copy:
src: environment_octave.yml
dest: /tmp
- name: setup the conda environment for octave
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_octave.yml --force
conda activate octave
jupyter kernelspec remove -f python3
conda deactivate
args:
executable: /bin/bash
- name: copy the conda environment file for R
copy:
src: environment_r.yml
dest: /tmp
- name: setup the conda environment for R
shell: |
source "{{ conda_root }}/etc/profile.d/conda.sh"
conda clean --all -y
conda env create -f /tmp/environment_r.yml --force
conda activate r
jupyter kernelspec remove -f python3
conda deactivate
args:
executable: /bin/bash