Skip to content

Commit

Permalink
Merge pull request #58 from ellisonbg/more-more-fixes
Browse files Browse the repository at this point in the history
Hopefully final fixes to get master working again...
  • Loading branch information
ellisonbg committed Jan 4, 2017
2 parents b368e97 + 6e76fed commit 9db7d99
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 109 deletions.
2 changes: 1 addition & 1 deletion ansible-conda
Submodule ansible-conda updated 1 files
+9 −9 conda.py
8 changes: 4 additions & 4 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
- common
- python
- role: r
when: install_r_kernel is defined and install_r_kernel != ''
when: install_r_kernel is defined and install_r_kernel
- role: newrelic
when: newrelic_license_key is defined and newrelic_license_key != ''
- nginx
- supervisor
- saveusers
- role: bash
when: install_bash_kernel is defined and install_bash_kernel != ''
when: install_bash_kernel is defined and install_bash_kernel
- jupyterhub
- role: cull_idle
when: use_cull_idle_servers is defined and use_cull_idle_servers != ''
when: use_cull_idle_servers is defined and use_cull_idle_servers
- role: nbgrader
when: use_nbgrader is defined and use_nbgrader != ''
when: use_nbgrader is defined and use_nbgrader
environment:
PATH: "/opt/conda/bin:{{ default_path.stdout }}"
8 changes: 4 additions & 4 deletions deploy_formgrade.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---

# This playbook is deployed separately and after `deploy.yml` since the
# instructor's user account must be set up before deploying formgrader

# Multiple formgrade instances can be run on a system, one for each course
# instructor's user account must be set up before deploying formgrader.

- hosts: jupyterhub_hosts
roles:
- formgrade
- role: formgrade
when: use_nbgrader is defined and use_nbgrader

9 changes: 8 additions & 1 deletion group_vars/jupyterhub_hosts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
# NOTE: You shouldn't have to change these, to customize this deployment
# for individual hosts, create and edit files in the host_vars folder.

# ---------------------------------------------------
# Ansible
# ---------------------------------------------------

# Path of the Python 2.7 interpreter on the remote server
# Note: Ansible requires Python 2.7 for provisioning so the path must be set
ansible_python_interpreter: '/usr/bin/python2.7'

# ---------------------------------------------------
# JupyterHub config directories
# ---------------------------------------------------
Expand Down Expand Up @@ -45,4 +53,3 @@ letsencrypt_ssl_cert_path: "/etc/letsencrypt/live/{{inventory_hostname}}/fullcha

nbgrader_log_dir: /var/log/nbgrader
nbgrader_exchange_dir: /srv/nbgrader/exchange
nbgrader_base_dir: "{{home_dir}}/{{nbgrader_owner}}/nbgrader/{{nbgrader_course_id}}"
180 changes: 104 additions & 76 deletions host_vars/hostname.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,43 @@
# An example `hostname` file
#
# Edit this file to customize settings for a particular host.
# Save as `hostname` without the `.example` suffix.
# Save as FQDN of the hostname without the `.example` suffix,
# such as `jupyterhub.myuniversity.edu`.

# ---------------------------------------------------
# ------------------------------------------------------------------------------
# Required settings
# ---------------------------------------------------
# ------------------------------------------------------------------------------

# The base directory of user accounts
# The base directory of user accounts.
home_dir: /home

# Users with administrative privileges
# Users with administrative privileges.
jupyterhub_admin_users:
- instructor

# Whitelist of jupyterhub users
# Whitelist of jupyterhub users.
jupyterhub_users:
- instructor
- grader
- student1
- student2

# R kernel installation (default: false)
# R kernel installation, set to true to enable.
install_r_kernel: false

# bash kernel installation
# bash kernel installation, set to true to enable
install_bash_kernel: true

# Secret token for proxy access
# Create token using something like `openssl rand -hex 32` and
# enter between quotation marks below
# Secret token for proxy access. Create token using something like `openssl rand
# -hex 32` and enter between quotation marks below.
proxy_auth_token: ''

# Path of the Python 2.7 interpreter on the remote server
# Note: Ansible requires Python 2.7 for provisioning so the path must be set
ansible_python_interpreter: '/usr/bin/python2.7'

# ---------------------------------------------------
# ------------------------------------------------------------------------------
# Packages
# ---------------------------------------------------
# ------------------------------------------------------------------------------

# Add or remove packages here for different package
# managers here (conda, pip, cran). The package listed
# here are on-top of the base installation of jupyter,
# Add or remove packages here for different package managers here (conda, pip,
# cran). The package listed here are on-top of the base installation of jupyter,
# ipython and the IPython and IR kernel.

conda_packages:
Expand All @@ -66,8 +61,6 @@ conda_packages:
- blaze
- odo
- altair
- tensorflow
- keras

pip_packages:
- brewer2mpl
Expand Down Expand Up @@ -139,80 +132,115 @@ cran_packages:
- RTextTools
- XLSX

# ---------------------------------------------------
# ------------------------------------------------------------------------------
# Optional settings
# ---------------------------------------------------
# ------------------------------------------------------------------------------

# To mount local file systems populate this list. (Optional)
# This adds the entries to /etc/fstab, creates the mount points,
# and mounts them. Note: Disks must be partitioned and formatted.
local_mounts: []
# - name: /mountpoint1
# src: /dev/sdb1
# fstype: ext3
# - name: /mountpoint2
# src: /dev/sdc1
# fstype: ext3

# SSL using letsencrypt (optional - use letsencrypt default: false)
# If using letsencrypt to generate SSL key/cert, set `use_letsencrypt` to `true`
# Otherwise if not using letsencrypt for SSL, you MUST put your key and cert into the security directory as
# `security/ssl.crt` and `security/ssl.key`
use_letsencrypt: false
letsencrypt_email: ''
# The following sections are for optional features that can be enabled.

# If users should have `/public_html/username` directories, set this to `true` (Optional)
nginx_public_html: false
# ------------------------------------------------------------------------------
# OAuth
# ------------------------------------------------------------------------------

# List of the GitHub usernames who will receive root access via ssh
# Public GitHub SSH keys will be installed to allow the user to ssh into the server as root.
github_usernames: ['instructor', 'grader']
# The default authentication will use PAM, which is the standard UNIX password
# standard. In the default configuration UNIX usernames and passwords will be
# used for JupyterHub. Enabling OAuth through an OAuth provider (such as GitHub)
# will enable users to log in using their username and passwords from the OAuth
# provider. In this case, new users can be added using the JupyterHub Admin
# page, and the users' home directories will be automatically created.

# Oauth (Optional - use oauth default: false)
# Change `use_oauth` to `true` and set the other values appropriately
# to enable GitHub OAuth.
# If left as default `false`, PAM authentication will be used.
# Set to `true` to enable.
use_oauth: false

# The OAuth callback URL.
oauth_callback_url: https://mydomain.org/hub/oauth_callback

# The OAuth client ID.
oauth_client_id: ''

# The OAuth client secret.
oauth_client_secret: ''

# Cull idle servers (Optional default: false)
# Enable or disable cull idle single user servers
use_cull_idle_servers: false
# The username for culling idle servers. MUST be a user of JupyterHub.
# For example, root won't work unless root can access JupyterHub.
cull_idle_servers_owner: instructor
# The API token for culling, create using something like `openssl rand -hex 32`
cull_idle_servers_hubapi_token: ''
# The interval (in seconds) for checking for idle servers to cull
cull_every: 600
# The idle timeout (in seconds)
cull_timeout: 3600
# ------------------------------------------------------------------------------
# nbgrader
# ------------------------------------------------------------------------------

# nbgrader is a system for assigning, collecting and grading notebook based
# homework assignments. For more details see:
# http://nbgrader.readthedocs.io/en/stable/

# nbgrader (Optional default: false)
# Set to `true` to enable.
use_nbgrader: false
# The API token formgrader will use to make Hub requests
# Create using something like `openssl rand -hex 32` and
# enter between quotation marks below

# The API token formgrader will use to make Hub requests Create using something
# like `openssl rand -hex 32` and enter between quotation marks below.
formgrader_hubapi_token: ''

# The list of nbgrader courses. Each must have a unique `course_id` and `port`.
nbgrader_courses:
- {
nbgrader_course_id: "course2",
nbgrader_owner: "instructor2",
nbgrader_graders: ["instructor2", "grader2"],
nbgrader_port: 5006
course_id: "course1",
owner: "instructor1",
graders: ["instructor1", "grader1"],
port: 5005
}
- {
nbgrader_course_id: "course2",
nbgrader_owner: "instructor2",
nbgrader_graders: ["instructor2", "grader2"],
nbgrader_port: 5006
course_id: "course2",
owner: "instructor2",
graders: ["instructor2", "grader2"],
port: 5006
}

# Set Google Analytics Tracking ID (Optional)
# ------------------------------------------------------------------------------
# cull_idle_servers
# ------------------------------------------------------------------------------

# Set to `true` to enable.
use_cull_idle_servers: false

# The API token for culling, create using something like `openssl rand -hex 32`
cull_idle_servers_hubapi_token: ''

# The interval (in seconds) for checking for idle servers to cull.
cull_every: 600

# The idle timeout (in seconds).
cull_timeout: 3600

# ------------------------------------------------------------------------------
# Misc optional settings
# ------------------------------------------------------------------------------

# List of the GitHub usernames who will receive root access via ssh. Public
# GitHub SSH keys will be installed to allow the user to ssh into the server as
# root.
github_usernames: ['instructor', 'grader']

# To mount local file systems populate this list. (Optional) This adds the
# entries to /etc/fstab, creates the mount points, and mounts them. Note: Disks
# must be partitioned and formatted.
local_mounts: []
# - name: /mountpoint1
# src: /dev/sdb1
# fstype: ext3
# - name: /mountpoint2
# src: /dev/sdc1
# fstype: ext3

# SSL using letsencrypt (optional - use letsencrypt default: false) If using
# letsencrypt to generate SSL key/cert, set `use_letsencrypt` to `true`
# Otherwise if not using letsencrypt for SSL, you MUST put your key and cert
# into the security directory as `security/ssl.crt` and `security/ssl.key`.
use_letsencrypt: false
letsencrypt_email: ''

# Should users have `/public_html/username` directories. Set this to `true` to
# enable.
nginx_public_html: false

# Set Google Analytics Tracking ID (Optional).
ga_tracking_id: ''

# Set NewRelic license key (Optional)
# Set NewRelic license key (Optional).
newrelic_license_key: ''

2 changes: 1 addition & 1 deletion roles/cull_idle/templates/cull_idle_servers.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ stdout_logfile={{ jupyterhub_log_dir }}/cull_idle_servers.log
autostart=true
autorestart=false
stopasgroup=true
user=nobody
user=root
directory={{jupyterhub_srv_dir}}
22 changes: 11 additions & 11 deletions roles/formgrade/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
---

- name: make sure base exists
file: path={{nbgrader_base_dir}}/ state={{item[0]}} owner={{item[1].nbgrader_owner}} mode=0700
file: path={{home_dir}}/{{item[0].owner}}/nbgrader/{{item[0].course_id}}/ state={{item[1]}} owner={{item[0].owner}} mode=0700
become: true
with_items:
- ['directory', 'touch']
with_nested:
- "{{nbgrader_courses}}"
- ['directory', 'touch']

- name: make sure subdirectories exist
file: path={{nbgrader_base_dir}}/{{item[0]}}/ state=directory owner={{item[1].nbgrader_owner}} mode=0700
file: path={{home_dir}}/{{item[0].owner}}/nbgrader/{{item[0].course_id}}/{{item[1]}}/ state=directory owner={{item[0].owner}} mode=0700
become: true
with_items:
- ['source', 'release', 'feedback', 'autograded', 'submitted']
with_nested:
- "{{nbgrader_courses}}"
- ['source', 'release', 'feedback', 'autograded', 'submitted']

- name: install nbgrader config file
template: "src=nbgrader_config.py.j2 dest={{nbgrader_base_dir}}/nbgrader_config.py owner={{item.nbgrader_owner}} mode=700"
template: src=nbgrader_config.py.j2 dest={{home_dir}}/{{item.owner}}/nbgrader/{{item.course_id}}/nbgrader_config.py owner={{item.owner}} mode=700
become: true
with_items:
- "{{nbgrader_courses}}"

- name: install supervisor config for nbgrader
template: "src=nbgrader.conf.j2 dest=/etc/supervisor/conf.d/nbgrader_{{item.nbgrader_course_id}}.conf owner=root group=root mode='0600' backup=yes"
template: src=nbgrader.conf.j2 dest=/etc/supervisor/conf.d/nbgrader_{{item.course_id}}.conf owner=root group=root mode='0600' backup=yes
become: true
with_items:
- "{{nbgrader_courses}}"

- name: load nbgrader supervisor config
supervisorctl: name=nbgrader_{{item.nbgrader_course_id}} state=present
supervisorctl: name=nbgrader_{{item.course_id}} state=present
become: true
with_items:
- "{{nbgrader_courses}}"

- name: start nbgrader with supervisor
supervisorctl: name=nbgrader_{{item.nbgrader_course_id}} state=restarted
supervisorctl: name=nbgrader_{{item.course_id}} state=restarted
become: true
with_items:
- "{{nbgrader_courses}}"
- "{{nbgrader_courses}}"
10 changes: 5 additions & 5 deletions roles/formgrade/templates/nbgrader.conf.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# {{ ansible_managed }}

[program:nbgrader_{{item.nbgrader_course_id}}]
[program:nbgrader_{{item.course_id}}]
command=/opt/conda/bin/nbgrader formgrade
redirect_stderr=true
stdout_logfile={{nbgrader_log_dir}}/nbgrader_{{item.nbgrader_course_id}}.log
stdout_logfile={{nbgrader_log_dir}}/nbgrader_{{item.course_id}}.log
autostart=true
autorestart=false
stopasgroup=true
user={{item.nbgrader_owner}}
directory={{nbgrader_base_dir}}/
environment=HOME="{{home_dir}}/{{item.nbgrader_owner}}",USER="{{item.nbgrader_owner}}",PATH="/opt/conda/bin:%(ENV_PATH)s"
user={{item.owner}}
directory={{home_dir}}/{{item.owner}}/nbgrader/{{item.course_id}}/
environment=HOME="{{home_dir}}/{{item.owner}}",USER="{{item.owner}}",PATH="/opt/conda/bin:%(ENV_PATH)s"

0 comments on commit 9db7d99

Please sign in to comment.