Ottomata has submitted this change and it was merged.

Change subject: Parametrize IPython notebook profile configuration
......................................................................


Parametrize IPython notebook profile configuration

Tell Puppet to create an IPython profile and to configure it according to
the parameters passed to the notebook class. Also add RDoc documentation for
parameters and set permission of $notebook_dir to 0664 (was: 0555).

Change-Id: Ib4c6e662740fc9c56f5c29bb58ce1badd535c89e
---
M modules/eventlogging/manifests/notebook.pp
A modules/eventlogging/templates/ipython_notebook_config.py.erb
M modules/eventlogging/templates/notebook.conf.erb
3 files changed, 70 insertions(+), 3 deletions(-)

Approvals:
  Ottomata: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/eventlogging/manifests/notebook.pp 
b/modules/eventlogging/manifests/notebook.pp
index acbc04e..b8ad0ca 100644
--- a/modules/eventlogging/manifests/notebook.pp
+++ b/modules/eventlogging/manifests/notebook.pp
@@ -1,11 +1,42 @@
+# == Class: eventlogging::notebook
+#
 # Configures an integrated, web-based numeric computation environment
 # (like Mathematica), based on PyLab and IPython Notebook.
 # See <http://ipython.org/ipython-doc/dev/interactive/htmlnotebook.html>
 # and <http://www.scipy.org/PyLab>.
+#
+# === Parameters
+#
+# [*ipython_dir*]
+#   IPython working directory.
+#
+# [*ipython_profile*]
+#   Name of IPython profile to create.
+#
+# [*ipython_user*]
+#   Create this user account and run IPython as this user.
+#
+# [*notebook_dir*]
+#   Specifies where IPython should archive notebooks.
+#
+# [*notebook_ip*]
+#   Interface on which the notebook server will listen (or '*' for all
+#   interfaces).
+#
+# [*notebook_port*]
+#   The port the notebook server will listen on.
+#
+# [*exec_files*]
+#   Array of Python files to execute at start of Notebook session.
+#
 class eventlogging::notebook(
        $ipython_dir = '/var/lib/ipython',
+       $ipython_profile = 'nbserver',
        $ipython_user = 'ipython',
-       $notebook_dir = '/var/lib/ipython/notebooks'
+       $notebook_dir = '/var/lib/ipython/notebooks',
+       $notebook_ip = '*',
+       $notebook_port = 8888,
+       $exec_files = []
 ) {
 
        package { [
@@ -28,10 +59,27 @@
                ensure  => directory,
                owner   => $ipython_user,
                group   => $ipython_user,
-               mode    => '0555',
+               mode    => '0664',
                require => Systemuser[$ipython_user],
        }
 
+       exec { "Create IPython profile ${ipython_profile}":
+               command     => "ipython profile create ${ipython_profile} 
--ipython-dir=\"${ipython_dir}\"",
+               creates     => "${ipython_dir}/profile_${ipython_profile}",
+               environment => "IPYTHONDIR=${ipython_dir}",
+               user        => $ipython_user,
+               require     => [ Package['ipython-notebook'], 
Systemuser[$ipython_user] ],
+       }
+
+       file { "Configure IPython profile ${ipython_profile}":
+               path    => 
"${ipython_dir}/profile_${ipython_profile}/ipython_notebook_config.py",
+               content => 
template('eventlogging/ipython_notebook_config.py.erb'),
+               require => Exec["Create IPython profile ${ipython_profile}"],
+               owner   => $ipython_user,
+               group   => $ipython_user,
+               mode    => '0444',
+       }
+
        file { '/etc/supervisor/conf.d/notebook.conf':
                content => template('eventlogging/notebook.conf.erb'),
                require => [ Package['ipython-notebook'], File[$notebook_dir] ],
diff --git a/modules/eventlogging/templates/ipython_notebook_config.py.erb 
b/modules/eventlogging/templates/ipython_notebook_config.py.erb
new file mode 100644
index 0000000..b881cbf
--- /dev/null
+++ b/modules/eventlogging/templates/ipython_notebook_config.py.erb
@@ -0,0 +1,16 @@
+# Configuration file for ipython-notebook.
+# This file is managed by Puppet.
+
+c = get_config()
+c.IPKernelApp.pylab = 'inline'
+c.NotebookApp.enable_mathjax = True
+c.NotebookApp.open_browser = False
+c.NotebookApp.ip = '<%= notebook_ip %>'
+c.NotebookApp.port = <%= notebook_port %>
+c.NotebookManager.notebook_dir = '<%= notebook_dir %>'
+
+c.InteractiveShellApp.exec_files = [
+<% exec_files.each do |file| -%>
+    '<%= file %>',
+<% end -%>
+]
diff --git a/modules/eventlogging/templates/notebook.conf.erb 
b/modules/eventlogging/templates/notebook.conf.erb
index 34d5ca7..89ddff2 100644
--- a/modules/eventlogging/templates/notebook.conf.erb
+++ b/modules/eventlogging/templates/notebook.conf.erb
@@ -1,5 +1,8 @@
+; supervisor configuration for ipython-notebook
+; This file is managed by Puppet.
+
 [program:notebook]
-command = ipython notebook --ipython-dir="<%= ipython_dir %>" --profile 
nbserver
+command = ipython notebook --ipython-dir="<%= ipython_dir %>" --profile="<%= 
ipython_profile %>"
 user = <%= ipython_user %>
 directory = <%= ipython_dir %>
 redirect_stderr = true

-- 
To view, visit https://gerrit.wikimedia.org/r/59782
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4c6e662740fc9c56f5c29bb58ce1badd535c89e
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Faidon <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to