Commit 3e9aaf41 authored by root's avatar root

added ansible files for deploying visa-jupyter

parent d1211bef
[defaults]
host_key_checking = false
---
# Run me with: ansible-playbook -i hosts setup_jupyterhub.yaml --ask-pass
- hosts: all
remote_user: root
roles:
- role: roles/apt-packages
- role: roles/create-jupyter-admin
- role: roles/install-conda
become_user: jupyter-admin
become: yes
become_method: "su"
become_flags: "-l"
- role: roles/setup-visa-jupyter-environment
become_user: jupyter-admin
become: yes
become_method: "su"
become_flags: "-l"
- role: roles/setup-scientific-environment
become_user: jupyter-admin
become: yes
become_method: "su"
become_flags: "-l"
- role: roles/setup-visa-jupyter-service
---
- hosts: all
remote_user: root
tasks:
- name: install public key
authorized_key:
user: root
state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
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 apt-package
\ No newline at end of file
---
# handlers file for apt-package
\ 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 apt-packages
- include: packages.yml
- name: install apt dependencies
apt:
name: ["freeglut3-dev","libglu1-mesa","imagemagick","git"]
update_cache: true
force_apt_get: yes
---
- hosts: localhost
remote_user: root
roles:
- apt-package
\ No newline at end of file
---
# vars file for apt-package
\ No newline at end of file
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 create-jupyter-admin
\ No newline at end of file
---
# handlers file for create-jupyter-admin
\ 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
- name: create jupyter-admin group
group:
name: jupyter-admin
- name: create jupyter admin with sudo priviledges
user:
name: jupyter-admin
# created with:
# python -c 'import crypt; print crypt.crypt("This is my Password")'
password: "$6$olQ.qEo9P.Qr2h1t$r2QN/y.4nZmu6OQIbDp5L59Sr2dx7wYlWuTTzlibUMDapOasDLlxvRuLjsKfahpkZ26K.RLoMcVHXH6qltx1o0"
state: present
shell: /bin/bash
system: no
createhome: yes
home: /jupyter-admin
group: jupyter-admin
groups:
- sudo
---
# tasks file for create-jupyter-admin
- include: create-jupyter-admin.yml
---
- hosts: localhost
remote_user: root
roles:
- create-jupyter-admin
\ No newline at end of file
---
# vars file for create-jupyter-admin
\ No newline at end of file
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 install-conda
\ No newline at end of file
---
# handlers file for install-conda
\ 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
- name: remove existing miniconda installer
file:
path: ~/Miniconda3-latest-Linux-x86_64.sh
state: absent
- name: remove miniconda3 target directory
file:
path: ~/miniconda3
state: absent
- name: download latest miniconda
get_url:
url: https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
dest: ~/Miniconda3-latest-Linux-x86_64.sh
mode: u+x
- name: install conda
shell: |
~/Miniconda3-latest-Linux-x86_64.sh -b
eval "$(~/miniconda3/bin/conda shell.bash hook)"
conda init
conda update -y conda
args:
executable: /bin/bash
- name: update bash_profile
lineinfile:
path: ~/.bash_profile
line: . ~/miniconda3/etc/profile.d/conda.sh
state: present
regexp: ".*miniconda3.*"
---
# tasks file for install-conda
- include: install-conda.yml
---
- hosts: localhost
remote_user: root
roles:
- install-conda
\ No newline at end of file
---
# vars file for install-conda
\ No newline at end of file
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 setup-scientific-environment
\ No newline at end of file
{
"argv": [
"python3",
"-m",
"jupyter_fortran_kernel",
"-f",
"{connection_file}"
],
"display_name": "Fortran",
"language": "Fortran"
}
---
# handlers file for setup-scientific-environment
\ 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 setup-scientific-environment
- 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
- name: setup the bash environment
shell: |
source ~/.bash_profile
conda env create -f ~/git/visa-jupyter/conda/environment_bash.yml --force
conda activate bash
jupyter kernelspec remove -f python3
conda deactivate
args:
executable: /bin/bash
- name: install bash kernel
shell: |
source ~/.bash_profile
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: ~/.local/share/jupyter/kernels/bash
dest: ~/miniconda3/envs/bash/share/jupyter/kernels/
remote_src: yes
- name: remove the bash kernel located in .local
file:
path: ~/.local/share/jupyter/kernels/bash
state: absent
- name: fetch a bash logo
get_url:
url: https://www.shareicon.net/data/512x512/2016/06/19/603811_prog_512x512.png
dest: ~/bash_logo.png
- name: resize the bash logo and copy the resized logo to kernel location
shell: |
convert bash_logo.png -resize 32x32 ~/miniconda3/envs/bash/share/jupyter/kernels/bash/logo-32x32.png
convert bash_logo.png -resize 64x64 ~/miniconda3/envs/bash/share/jupyter/kernels/bash/logo-64x64.png
- name: remove the bash logo
file:
path: ~/bash_logo.png
state: absent
- name: setup the cpp environment
shell: |
source ~/.bash_profile
conda env create -f ~/git/visa-jupyter/conda/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: setup the data analysis environment
shell: |
source ~/.bash_profile
conda env create -f ~/git/visa-jupyter/conda/environment_data_analysis.yml --force
args:
executable: /bin/bash
- name: setup the data reduction environment
shell: |
source ~/.bash_profile
conda env create -f ~/git/visa-jupyter/conda/environment_data_reduction.yml --force
args:
executable: /bin/bash
- name: fetch the Mantid logo
get_url:
url: https://www.mantidproject.org/skins/Strapping/images/Mantid_Logo_Transparent_wiki.png
dest: ~/mantid.png
- name: resize Mantid logo
shell: |
convert mantid.png -resize 32x32 ~/miniconda3/envs/data-reduction/share/jupyter/kernels/python3/logo-32x32.png
convert mantid.png -resize 64x64 ~/miniconda3/envs/data-reduction/share/jupyter/kernels/python3/logo-64x64.png
- name: remove Mantid logo
file:
path: ~/mantid.png
state: absent
- name: setup the fortran environment
shell: |
source ~/.bash_profile
conda env create -f ~/git/visa-jupyter/conda/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: ~/miniconda3/envs/fortran/share/jupyter/kernels/fortran
state: directory
- name: copy fortran kernel file
copy:
src: fortran-kernel.json