Skip to content

Commit

Permalink
T12828: Use the pywikibot-config repo for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
redbluegreenhat committed Nov 1, 2024
1 parent ab5f65d commit 3f6793a
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 51 deletions.
45 changes: 28 additions & 17 deletions modules/irc/manifests/pywikibot.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
require => Git::Clone['PyWikiBot'],
}

$family_langs = loadyaml('/etc/puppetlabs/puppet/pywikibot-config/langs.yaml')

file { "${base_path}/families/wikitide_family.py":
ensure => present,
owner => 'irc',
Expand All @@ -88,23 +90,32 @@
require => Git::Clone['PyWikiBot'],
}

cron { 'run pywikibot archivebot on meta':
ensure => present,
command => '/usr/local/bin/pywikibot archivebot Template:Autoarchive/config -pt:0 >> /var/log/pwb/archivebot-cron.log 2>&1',
user => 'irc',
minute => '0',
hour => '0',
}
$pwb_crons = loadyaml('/etc/puppetlabs/puppet/pywikibot-config/cron.yaml')

logrotate::rule { 'pwb-archivebot-cron':
file_glob => '/var/log/pwb/archivebot-cron.log',
frequency => 'weekly',
date_ext => true,
date_yesterday => true,
copy_truncate => true,
rotate => 7,
missing_ok => true,
no_create => true,
compress => true,
$pwb_crons.each |$dbname, $params| {
$params['scripts'].each |$ensure, $script, $scriptparams, $hour, $minute, $month, $monthday| {
# lint:ignore:selector_inside_resource
cron { "pywikibot ${dbname}-${script}":
ensure => $ensure,
command => '/usr/local/bin/pywikibot ${script} ${scriptparams} -lang:${dbname} -pt:0 >> /var/log/pwb/${dbname}-${script}-cron.log',
user => 'irc',
minute => $minute,
hour => $hour,
month => $month,
monthday => $monthday,
}
# lint:ignore:selector_inside_resource
logrotate::rule { "pwb-${dbname}-${script}-cron":
file_glob => '/var/log/pwb/${dbname}-${script}-cron.log',
frequency => 'weekly',
date_ext => true,
date_yesterday => true,
copy_truncate => true,
rotate => 7,
missing_ok => true,
no_create => true,
compress => true,
}
}
}
}
7 changes: 4 additions & 3 deletions modules/irc/templates/pywikibot/user-config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MANAGED BY PUPPET
family = 'wikitide'
mylang = 'meta'
usernames['wikitide']['meta'] = 'BeeBot'
authenticate['*.miraheze.org'] = ('<%= @consumer_token %>', '<%= @consumer_secret %>', '<%= @access_token %>', '<%= @access_secret %>')
mylang = 'metawiki'
usernames['wikitide']['*']: 'BeeBot',
authenticate['*'] = ('<%= @consumer_token %>', '<%= @consumer_secret %>', '<%= @access_token %>', '<%= @access_secret %>')
user_agent_description = 'https://meta.miraheze.org/wiki/Tech:Pywikibot; [email protected]'
66 changes: 35 additions & 31 deletions modules/irc/templates/pywikibot/wikitide_family.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
"""
This family file was auto-generated by generate_family_file.py script.
Configuration parameters:
url = https://meta.miraheze.org
name = meta
Please do not commit this to the Git repository!
"""
from pywikibot import family


class Family(family.Family): # noqa: D101

name = 'wikitide'
langs = {
'meta': 'meta.miraheze.org',
'test': 'test.miraheze.org',
}

def scriptpath(self, code):
return {
'meta': '/w',
'test': '/w',
}[code]

def protocol(self, code):
return {
'meta': 'https',
'test': 'https',
}[code]
# MANAGED BY PUPPET
"""
This family file was auto-generated by generate_family_file.py script.
Configuration parameters:
url = https://meta.miraheze.org
name = meta
Please do not commit this to the Git repository!
"""
from pywikibot import family


class Family(family.Family): # noqa: D101

name = 'wikitide'
langs = {
<% family_langs.each |$dbname, $params| {-%>
'<%= $dbname %>': '<%= $params[domain] %>',
<% } -%>
}

def scriptpath(self, code):
return {
<% family_langs.each |$dbname, $params| {-%>
'<%= $dbname %>': '/w',
<% } -%>
}[code]

def protocol(self, code):
return {
<% family_langs.each |$dbname, $params| {-%>
'<%= $dbname %>': 'https',
<% } -%>
}[code]
9 changes: 9 additions & 0 deletions modules/puppetserver/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@
require => Package['puppet-agent'],
}

git::clone { 'pywikibot-config':
ensure => latest,
directory => '/etc/puppetlabs/puppet/pywikibot-config',
origin => 'https://github.com/miraheze/pywikibot-config',
owner => 'puppet',
group => 'puppet',
require => Package['puppet-agent'],
}

file { '/etc/puppetlabs/puppet/private':
ensure => directory,
}
Expand Down

0 comments on commit 3f6793a

Please sign in to comment.