Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/258711
Change subject: Add vagrant role for pywikibot
......................................................................
Add vagrant role for pywikibot
Change-Id: I12d6c247bb376cff984e4e5b91430c5aa687990c
---
M puppet/hieradata/common.yaml
A puppet/modules/role/files/pywikibot/password
A puppet/modules/role/manifests/pywikibot.pp
A puppet/modules/role/templates/pywikibot/user-config.py.erb
A puppet/modules/role/templates/pywikibot/vagrant_family.py.erb
5 files changed, 102 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant
refs/changes/11/258711/1
diff --git a/puppet/hieradata/common.yaml b/puppet/hieradata/common.yaml
index af91aa7..00bc9e5 100644
--- a/puppet/hieradata/common.yaml
+++ b/puppet/hieradata/common.yaml
@@ -281,6 +281,8 @@
# result of
MediaWiki\Extensions\OAuth\MWOAuthUtils::hmacDBSecret(role::oauth::example_secret_key);
role::oauth::example_consumer_secret: b7cd84d1c419c8e62c1cd106afc4bc959fcf48c8
+role::pywikibot::dir: "%{hiera('mwv::services_dir')}/pywikibot"
+
role::sentry::dsn: "%{hiera('sentry::dsn_file')}"
role::wikimetrics::dir: "%{hiera('mwv::services_dir')}/wikimetrics"
diff --git a/puppet/modules/role/files/pywikibot/password
b/puppet/modules/role/files/pywikibot/password
new file mode 100644
index 0000000..3dc64cc
--- /dev/null
+++ b/puppet/modules/role/files/pywikibot/password
@@ -0,0 +1,2 @@
+('vagrant', 'Admin', 'vagrant')
+
diff --git a/puppet/modules/role/manifests/pywikibot.pp
b/puppet/modules/role/manifests/pywikibot.pp
new file mode 100644
index 0000000..c4b249a
--- /dev/null
+++ b/puppet/modules/role/manifests/pywikibot.pp
@@ -0,0 +1,56 @@
+# == Class: role::pywikibot
+#
+# Installs pywikibot[https://www.mediawiki.org/wiki/Manual:Pywikibot],
+# configured to work with the local wiki.
+#
+# === Parameters
+#
+# [*dir*]
+# The directory to install the bot into. It should not exist and
+# will be created.
+#
+# [*config_dir*]
+# The directory where the pywikibot configuration files will be stored.
+#
+class role::pywikibot (
+ $dir,
+ $config_dir = '/home/vagrant/.pywikibot',
+) {
+ git::clone { 'pywikibot/core':
+ directory => $dir,
+ }
+
+ env::profile_script { 'pywikibot in python path':
+ content => "export PYTHONPATH=\$PYTHONPATH:$dir
PYWIKIBOT2_DIR=${config_dir}",
+ }
+
+ exec { 'install pywikibot dependencies':
+ command => 'pip install -r requirements.txt --allow-external pYsearch
--allow-unverified pYsearch',
+ cwd => $dir,
+ require => Git::Clone['pywikibot/core'],
+ }
+
+ file { "${dir}/pywikibot/families/vagrant_family.py":
+ content => template('role/pywikibot/vagrant_family.py.erb'),
+ owner => $::share_owner,
+ group => $::share_group,
+ require => Git::Clone['pywikibot/core'],
+ }
+
+ # these need to be owned by the user who runs the bot
+ file { $config_dir:
+ ensure => directory,
+ }
+ file { "${config_dir}/user-config.py":
+ content => template('role/pywikibot/user-config.py.erb'),
+ replace => false,
+ }
+ file { "${config_dir}/.password":
+ source => 'puppet:///modules/role/pywikibot/password',
+ replace => false,
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => '0600',
+ }
+}
+
diff --git a/puppet/modules/role/templates/pywikibot/user-config.py.erb
b/puppet/modules/role/templates/pywikibot/user-config.py.erb
new file mode 100644
index 0000000..97e0e0a
--- /dev/null
+++ b/puppet/modules/role/templates/pywikibot/user-config.py.erb
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
+
+family = 'vagrant'
+mylang = 'wiki'
+
+usernames['vagrant']['*'] = u'Admin'
+sysopnames['vagrant']['*'] = u'Admin'
+password_file = '<%= @config_dir %>/.password'
+
+log = ['*'] # elements are script names and 'comm', 'data', 'wiki', 'bot'
+verbose_output = 0
+debug_log = []
+
diff --git a/puppet/modules/role/templates/pywikibot/vagrant_family.py.erb
b/puppet/modules/role/templates/pywikibot/vagrant_family.py.erb
new file mode 100644
index 0000000..e631690
--- /dev/null
+++ b/puppet/modules/role/templates/pywikibot/vagrant_family.py.erb
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+
+from pywikibot import family
+from pywikibot.tools import deprecated
+
+import os
+from collections import Mapping
+
+dir = '<%= scope['::mediawiki::multiwiki::settings_root'] %>'
+wikis = [i for i in os.listdir(dir) if os.path.isdir(os.path.join(dir, i))]
+domain_template = u'%s<%= scope['::mediawiki::multiwiki::base_domain'] %><%=
scope['::port_fragment'] %>'
+
+class Family(family.Family):
+ def __init__(self):
+ family.Family.__init__(self)
+ self.name = 'vagrant'
+ self.langs = dict({code: domain_template % code for code in wikis},
wiki=u'localhost')
+
+ def scriptpath(self, code):
+ return '/w'
+
+ @deprecated('APISite.version()')
+ def version(self, code):
+ return u'1.27alpha'
+
+ def protocol(self, code):
+ return u'http'
+
--
To view, visit https://gerrit.wikimedia.org/r/258711
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I12d6c247bb376cff984e4e5b91430c5aa687990c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits