Alexandros Kosiaris has submitted this change and it was merged.

Change subject: Puppetise Citoid's configuration
......................................................................


Puppetise Citoid's configuration

localsettings.js is now controlled by puppet with the information from
the citoid class, as well as the LVS config, thus keeping it updated
with any eventual changes there. Also, because of this change, the
service now reads its config from /etc/citoid/localsettings.js rather
than the file deployed with the repository.

Bug: T89875
Change-Id: I3ceb235edbabbe48a00633c428c51b0588f98b9b
---
A hieradata/common/citoid.yaml
M modules/citoid/manifests/init.pp
A modules/citoid/templates/localsettings.js.erb
M modules/citoid/templates/upstart-citoid.erb
4 files changed, 82 insertions(+), 3 deletions(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/hieradata/common/citoid.yaml b/hieradata/common/citoid.yaml
new file mode 100644
index 0000000..bde4591
--- /dev/null
+++ b/hieradata/common/citoid.yaml
@@ -0,0 +1,4 @@
+port: 1970
+http_proxy: url-downloader.wikimedia.org:8080
+zotero_host: zotero.svc.eqiad.wmnet
+zotero_port: 1969
diff --git a/modules/citoid/manifests/init.pp b/modules/citoid/manifests/init.pp
index e7bfc88..e8826ac 100644
--- a/modules/citoid/manifests/init.pp
+++ b/modules/citoid/manifests/init.pp
@@ -5,9 +5,24 @@
 # === Parameters
 #
 # [*port*]
-#   Port where to run the citoid service. Defaults to 1970.
+#   Port where to run the citoid service
 #
-class citoid( $port = 1970 ) {
+# [*http_proxy*]
+#   URL of the proxy to use, defaults to the one set for zotero
+#
+# [*zotero_host*]
+#   Host of the zotero service
+#
+# [*zotero_port*]
+#   Port of the zotero service
+#
+class citoid(
+    $port        = undef,
+    $http_proxy  = undef,
+    $zotero_host = undef,
+    $zotero_port = undef
+) {
+
     require_package('nodejs')
 
     package { 'citoid/deploy':
@@ -26,6 +41,26 @@
         shell  => '/bin/false',
         system => true,
         before => Service['citoid'],
+    }
+
+    file { '/etc/citoid':
+        ensure => directory,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0755',
+    }
+
+    file { '/etc/citoid/localsettings.js':
+        ensure  => present,
+        content => template('citoid/localsettings.js.erb'),
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        require => [
+            Package['citoid/deploy'],
+            File['/etc/citoid'],
+        ],
+        notify  => Service['citoid'],
     }
 
     file { '/var/log/citoid':
@@ -56,5 +91,7 @@
         hasstatus  => true,
         hasrestart => true,
         provider   => 'upstart',
+        require    => Package['nodejs', 'citoid/deploy'],
     }
+
 }
diff --git a/modules/citoid/templates/localsettings.js.erb 
b/modules/citoid/templates/localsettings.js.erb
new file mode 100644
index 0000000..a116cdb
--- /dev/null
+++ b/modules/citoid/templates/localsettings.js.erb
@@ -0,0 +1,38 @@
+/*
+ * NOTE: This file is managed by puppet
+ *
+ * Citoud configuration file
+ */
+
+var CitoidConfig = {
+
+       // Allow cross-domain requests to the API (default '*')
+       // Sets Access-Control-Allow-Origin header
+       // enable:
+       allowCORS : '*',
+       // disable:
+       //allowCORS : false,
+       // restrict:
+       //allowCORS : 'some.domain.org',
+
+       // Set proxy for outgoing requests
+       proxy : <%= @http_proxy %>,
+
+       // Allow override of port/interface:
+       citoidPort : <%= @port %>,
+       citoidInterface : '0.0.0.0',
+
+       // userAgent string for lib/Scraper.js
+       userAgent : 'WikimediaBot',
+
+       // Settings for Zotero server
+       zoteroPort : <%= @zotero_port %>,
+       zoteroInterface : '<%= @zotero_host %>',
+       // Whether or not the outbound proxy should be used to access Zotero
+       zoteroUseProxy : false,
+};
+
+/*Exports*/
+module.exports = CitoidConfig;
+
+
diff --git a/modules/citoid/templates/upstart-citoid.erb 
b/modules/citoid/templates/upstart-citoid.erb
index 7a4fa0e..3df55d9 100644
--- a/modules/citoid/templates/upstart-citoid.erb
+++ b/modules/citoid/templates/upstart-citoid.erb
@@ -20,4 +20,4 @@
 kill timeout 60
 
 chdir /srv/deployment/citoid/deploy
-exec /usr/bin/nodejs src/server.js -c localsettings.js >> 
/var/log/citoid/main.log 2>&1
+exec /usr/bin/nodejs src/server.js -c /etc/citoid/localsettings.js >> 
/var/log/citoid/main.log 2>&1

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3ceb235edbabbe48a00633c428c51b0588f98b9b
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Mvolz <mv...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to