From: Grant Slater Date: Sat, 4 Mar 2017 15:36:44 +0000 (+0000) Subject: mediawiki: parsoid switch to yaml config X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/94e8307dd58105891f5af81c06b3d8336deb75cb mediawiki: parsoid switch to yaml config --- diff --git a/cookbooks/mediawiki/recipes/default.rb b/cookbooks/mediawiki/recipes/default.rb index 20b5f6f3e..b31db999d 100644 --- a/cookbooks/mediawiki/recipes/default.rb +++ b/cookbooks/mediawiki/recipes/default.rb @@ -54,15 +54,16 @@ package "parsoid" # Mediawiki packages for SyntaxHighight support package "python-pygments" -# parsoid 0.6.1all is broken with Ubuntu 16.04+ version of node. Monkey patch a fix. -link "/usr/lib/parsoid/lib" do - to "/usr/lib/parsoid/src/lib" - link_type :symbolic - not_if { File.exist?("/usr/lib/parsoid/lib") } +file "/usr/lib/parsoid/lib" do + action :delete end -template "/etc/mediawiki/parsoid/settings.js" do - source "parsoid-settings.js.erb" +file "/etc/mediawiki/parsoid/settings.js" do + action :delete +end + +template "/etc/mediawiki/parsoid/config.yaml" do + source "parsoid-config.yaml.erb" owner "root" group "root" mode 0o644 @@ -71,8 +72,8 @@ end service "parsoid" do action [:enable] supports :status => false, :restart => true, :reload => false - subscribes :restart, "template[/etc/mediawiki/parsoid/settings.js]" - subscribes :restart, "link[/usr/lib/parsoid/lib]" + subscribes :restart, "file[/etc/mediawiki/parsoid/settings.js]" + subscribes :restart, "template[/etc/mediawiki/parsoid/config.yaml]" end apache_module "php7.0" diff --git a/cookbooks/mediawiki/templates/default/parsoid-config.yaml.erb b/cookbooks/mediawiki/templates/default/parsoid-config.yaml.erb new file mode 100644 index 000000000..0ffb01330 --- /dev/null +++ b/cookbooks/mediawiki/templates/default/parsoid-config.yaml.erb @@ -0,0 +1,92 @@ +# DO NOT EDIT - This file is being maintained by Chef + +worker_heartbeat_timeout: 300000 + +logging: + level: info + +#metrics: +# type: log + +services: + - module: src/lib/index.js + entrypoint: apiServiceWorker + conf: + # For backwards compatibility, and to continue to support non-static + # configs for the time being, optionally provide a path to a + # localsettings.js file. See localsettings.example.js + #localsettings: ./localsettings.js + + # Set your own user-agent string + # Otherwise, defaults to: + # 'Parsoid/' + #userAgent: 'My-User-Agent-String' + + # Configure Parsoid to point to your MediaWiki instances. + mwApis: + # - # This is the only required parameter, + # the URL of you MediaWiki API endpoint. + # uri: 'http://localhost/w/api.php' + # The "domain" is used for communication with Visual Editor + # and RESTBase. It defaults to the hostname portion of + # the `uri` property below, but you can manually set it + # to an arbitrary string. + # domain: 'localhost' # optional + # To specify a proxy (or proxy headers) specific to this prefix + # (which overrides defaultAPIProxyURI). Alternatively, set `proxy` + # to `null` to override and force no proxying when a default proxy + # has been set. + #proxy: + # uri: 'http://my.proxy:1234/' + # headers: # optional + # 'X-Forwarded-Proto': 'https' +<% node[:mediawiki][:sites].keys.sort.each do |site_url| -%> + - # This is the only required parameter, + uri: 'http://<%= site_url %>/w/api.php' +<% end -%> + + # We pre-define wikipedias as 'enwiki', 'dewiki' etc. Similarly + # for other projects: 'enwiktionary', 'enwikiquote', 'enwikibooks', + # 'enwikivoyage' etc. + # The default for this is false. Uncomment the line below if you want + # to load WMF's config for wikipedias, etc. + #loadWMF: true + + # A default proxy to connect to the API endpoints. + # Default: undefined (no proxying). + # Overridden by per-wiki proxy config in setMwApi. + #defaultAPIProxyURI: 'http://proxy.example.org:8080' + + # Enable debug mode (prints extra debugging messages) + #debug: true + + # Use the PHP preprocessor to expand templates via the MW API (default true) + #usePHPPreProcessor: false + + # Use selective serialization (default false) + useSelser: true + + # Allow cross-domain requests to the API (default '*') + # Sets Access-Control-Allow-Origin header + # disable: + #allowCORS: false + # restrict: + #allowCORS: 'some.domain.org' + + # Allow override of port/interface: + #serverPort: 8000 + #serverInterface: '127.0.0.1' + + # Enable linting of some wikitext errors to the log + #linting: true + # Send lint errors to MW API instead of to the log + #linterSendAPI: false + + # Require SSL certificates to be valid (default true) + # Set to false when using self-signed SSL certificates + #strictSSL: false + + # Use a different server for CSS style modules. + # Leaving it undefined (the default) will use the same URI as the MW API, + # changing api.php for load.php. + #modulesLoadURI: 'http://example.org/load.php' diff --git a/cookbooks/mediawiki/templates/default/parsoid-settings.js.erb b/cookbooks/mediawiki/templates/default/parsoid-settings.js.erb deleted file mode 100644 index 896064bdc..000000000 --- a/cookbooks/mediawiki/templates/default/parsoid-settings.js.erb +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This is a sample configuration file. - * - * Copy this file to localsettings.js and edit that file to fit your needs. - * - * Also see: - * - api/server.js for more information about passing config files via - * the commandline. - * - lib/mediawiki.ParsoidConfig.js all the properties - * that you can configure here. Not all properties are - * documented here. - */ -'use strict'; - -exports.setup = function(parsoidConfig) { - // Set your own user-agent string - // Otherwise, defaults to "Parsoid/" - //parsoidConfig.userAgent = "My-User-Agent-String"; - - // The URL of your MediaWiki API endpoint. - //parsoidConfig.setMwApi({ prefix: 'localhost', uri: 'http://localhost/w/api.php' }); - - <% node[:mediawiki][:sites].keys.sort.each do |site_url| -%> - parsoidConfig.setMwApi({ uri: 'http://<%= site_url %>/w/api.php' }); - <% end -%> - - // To specify a proxy (or proxy headers) specific to this prefix (which - // overrides defaultAPIProxyURI) use: - /* - parsoidConfig.setMwApi({ - prefix: 'localhost', - uri: 'http://localhost/w/api.php', - // set `proxy` to `null` to override and force no proxying. - proxy: { - uri: 'http://my.proxy:1234/', - headers: { 'X-Forwarded-Proto': 'https' } // headers are optional - } - }); - */ - - // We pre-define wikipedias as 'enwiki', 'dewiki' etc. Similarly - // for other projects: 'enwiktionary', 'enwikiquote', 'enwikibooks', - // 'enwikivoyage' etc. (default true) - //parsoidConfig.loadWMF = false; - - // A default proxy to connect to the API endpoints. - // Default: undefined (no proxying). - // Overridden by per-wiki proxy config in setMwApi. - //parsoidConfig.defaultAPIProxyURI = 'http://proxy.example.org:8080'; - - // Enable debug mode (prints extra debugging messages) - //parsoidConfig.debug = true; - - // Use the PHP preprocessor to expand templates via the MW API (default true) - //parsoidConfig.usePHPPreProcessor = false; - - // Use selective serialization (default false) - parsoidConfig.useSelser = true; - - // Allow cross-domain requests to the API (default '*') - // Sets Access-Control-Allow-Origin header - // disable: - //parsoidConfig.allowCORS = false; - // restrict: - //parsoidConfig.allowCORS = 'some.domain.org'; - - // Set to true for using the default performance metrics reporting to statsd - // If true, provide the statsd host/port values - /* - parsoidConfig.useDefaultPerformanceTimer = true; - parsoidConfig.txstatsdHost = 'statsd.domain.org'; - parsoidConfig.txstatsdPort = 8125; - */ - - // Alternatively, define performanceTimer as follows: - /* - parsoidConfig.performanceTimer = { - timing: function(metricName, time) { }, // do-something-with-it - count: function(metricName, value) { }, // do-something-with-it - }; - */ - - // How often should we emit a heap sample? Time in ms. - // This setting is only relevant if you have enabled - // performance monitoring either via the default metrics - // OR by defining your own performanceTimer properties - //parsoidConfig.heapUsageSampleInterval = 5 * 60 * 1000; - - // Allow override of port/interface: - //parsoidConfig.serverPort = 8000; - //parsoidConfig.serverInterface = '127.0.0.1'; - - // The URL of your LintBridge API endpoint - //parsoidConfig.linterAPI = 'http://lintbridge.wmflabs.org/add'; - - // Require SSL certificates to be valid (default true) - // Set to false when using self-signed SSL certificates - //parsoidConfig.strictSSL = false; - - // Use a different server for CSS style modules. - // Set to true to use bits.wikimedia.org, or to a string with the URI. - // Leaving it undefined (the default) will use the same URI as the MW API, - // changing api.php for load.php. - //parsoidConfig.modulesLoadURI = true; - - // Suppress some warnings from the Mediawiki API - // (defaults to suppressing warnings which the Parsoid team knows to - // be harmless) - //parsoidConfig.suppressMwApiWarnings = /annoying warning|other warning/; -};