forked from ipython/salt-states-nbviewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.sls
115 lines (102 loc) · 3.21 KB
/
init.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Handle naming differences for current production boxes, future boxes,
# Travis CI.
{% if grains['os'] == 'Ubuntu' %}
{% if grains['osrelease'] in ['12.10', '13.04', '13.10', '14.04'] %}
{% set libmemcached = "libmemcached10" %}
{% else %} # grains['osrelease'] == '12.04' %}
{% set libmemcached = "libmemcached6" %}
{% endif %}
{% else %}
# Default to libmemcached6 otherwise
{% set libmemcached = "libmemcached6" %}
{% endif %}
# nbviewer binary dependencies
packages:
pkg:
- installed
- names:
- git
- libzmq3-dev
- pandoc
- libevent-dev
- libcurl4-openssl-dev
- libmemcached-dev
- {{ libmemcached }}
- supervisor
- nodejs
# Pull down the latest and greatest ipython, unless pillar has something else for us
ipython-git:
git.latest:
- name: {{ salt['pillar.get']('ipython:location', 'https://github.com/ipython/ipython.git') }}
- rev: {{ salt['pillar.get']('ipython:rev', 'master') }}
- target: /usr/share/ipython
- force: true
- force_checkout: true
- submodules: true
- require:
- pkg: git
# Pull down the current codebase of nbviewer from github, unless pillar has something else for us
nbviewer-git:
git.latest:
- name: {{ salt['pillar.get']('nbviewer:location', 'https://github.com/ipython/nbviewer.git') }}
- rev: {{ salt['pillar.get']('nbviewer:rev', 'master') }}
- target: /usr/share/nbviewer
- force: true
- force_checkout: true
- require:
- pkg: git
# Log the deploy, mostly for sanity
logdeploy:
cmd.run:
- name: "cd /usr/share/nbviewer && git log -1 --format='Deployed nbviewer %h %s' | logger"
# Install IPython + deps
pre-create-venv:
virtualenv.manage:
- name: /usr/share/nbviewer/venv
- clear: false
ipython-pip:
pip.installed:
- editable: /usr/share/ipython/[nbconvert]
- bin_env: /usr/share/nbviewer/venv/
- upgrade: true
# Install all the dependencies for nbviewer via its requirements.txt into a virtualenv
/usr/share/nbviewer/venv:
virtualenv.manage:
- requirements: /usr/share/nbviewer/requirements.txt
- clear: false
- require:
- pkg: libmemcached-dev
# nbviewer gets managed by supervisor
nbviewer:
supervisord:
- running
- require:
- pkg: supervisor
- watch:
- file: /etc/supervisor/conf.d/nbviewer.conf
/usr/share/nbviewer/newrelic.ini:
file.managed:
- source: salt://newrelic/newrelic.ini
- template: jinja
- mode: 644
# Manage the service with nbviewer
/etc/supervisor/conf.d/nbviewer.conf:
file.managed:
- source: salt://supervisor/nbviewer.conf.jinja
- template: jinja
- mode: 644
- context:
new_relic_config_file: /usr/share/nbviewer/newrelic.ini
environment: '{{ salt['pillar.get']('supervisor:environment', '')}}'
- watch:
- file: /usr/share/nbviewer/newrelic.ini
# Reread any configuration file changes
reread:
cmd.run:
- name: supervisorctl reread
- watch:
- file: /etc/supervisor/conf.d/nbviewer.conf
# Restart the process in case of code or environment variable updates
restart:
cmd.run:
- name: supervisorctl restart nbviewer