Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Configure salt state to use password and jupyter config
Browse files Browse the repository at this point in the history
  • Loading branch information
quasiben committed Jan 12, 2017
1 parent 52e3bcc commit 7546b15
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
9 changes: 9 additions & 0 deletions dask_ec2/formulas/salt/jupyter/notebook/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ include:
- jupyter
- supervisor
jupyter_notebook_config.py:
file.managed:
- name: {{ jupyter_config_dir ~ 'jupyter_notebook_config.py' }}
- makedirs: true
- source: salt://jupyter/templates/jupyter_notebook_config_py
- template: jinja
- user: {{ user }}
- group: {{ user }}
jupyter-notebook.conf:
file.managed:
- name: {{ conf_d }}/jupyter-notebook.conf
Expand Down
4 changes: 4 additions & 0 deletions dask_ec2/formulas/salt/jupyter/notebook/settings.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{%- from 'conda/settings.sls' import install_prefix with context -%}
{% set password = salt['pillar.get']('jupyter:password', 'jupyter') %}
{%- set hash_password = salt["cmd.run"](install_prefix ~ "/bin/python -c 'from notebook.auth import passwd; print(passwd(\"" ~ password ~ "\"))'") -%}
8 changes: 5 additions & 3 deletions dask_ec2/formulas/salt/jupyter/settings.sls
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{%- set user = 'ubuntu' %}

{% set user = salt['pillar.get']('cluster:username', 'ubuntu') %}

{%- set home_dir = salt['user.info'](user).home %}
{%- set jupyter_config_dir = home_dir ~ '/.jupyter/' %}
{%- set jupyter_config_dir = '/' ~ home_dir ~ '/.jupyter/' %}

{%- set port = 8888 %}
{%- set notebooks_dir = '/home/ubuntu/notebooks' %}
{%- set notebooks_dir = '/' ~ user ~ '/notebooks' %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{%- from 'jupyter/notebook/settings.sls' import ip, port, plain_password, hash_password with context -%}

c = get_config()

# Kernel config
c.IPKernelApp.pylab = "inline" # if you want plotting support always

# Notebook config
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.port_retries = 0
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'{{ hash_password }}'
4 changes: 4 additions & 0 deletions dask_ec2/formulas/salt/supervisor/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
supervisor-pkg:
pkg.installed:
- name: supervisor

supervisor:
service.running:
- enable: True

0 comments on commit 7546b15

Please sign in to comment.