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 2, 2024
1 parent ab5f65d commit 70641eb
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 53 deletions.
66 changes: 47 additions & 19 deletions modules/irc/manifests/pywikibot.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

file { '/usr/local/bin/pywikibot':
ensure => 'present',
owner => 'irc',
group => 'irc',
owner => 'root',
group => 'root',
mode => '0555',
content => template('irc/pywikibot/pywikibot.sh'),
}
Expand Down 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,49 @@
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.each |$script_config| {
# lint:ignore:selector_inside_resource
cron { "pywikibot ${dbname}-${script_config['name']}":
ensure => $ensure,
command => "/usr/local/bin/pywikibot ${script_config['script']} ${script_config['scriptparams']} -lang:${dbname} -pt:0 >> /var/log/pwb/${dbname}-${script_config['name']}-cron.log",
user => 'irc',
minute => $script_config['minute'] ? {
'*' => absent,
default => $script_config['minute'],
}
hour => $script_config['hour'] ? {
'*' => absent,
default => $script_config['hour']
}
month => $script_config['month'] ? {
'*' => absent,
default => $script_config['month']
}
monthday => $script_config['monthday'] ? {
'*' => absent,
default => $script_config['monthday']
}
weekday => $script_config['weekday'] ? {
'*' => absent,
default => $script_config['weekday']
}
}
# lint:ignore:selector_inside_resource
logrotate::rule { "pwb-${dbname}-${script_config['name']}-cron":
ensure => $ensure,
file_glob => "/var/log/pwb/${dbname}-${script_config['name']}-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]'
57 changes: 26 additions & 31 deletions modules/irc/templates/pywikibot/wikitide_family.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
"""
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
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 70641eb

Please sign in to comment.