Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T12828: Use the pywikibot-config repo for configuration #4071

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 67 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,69 @@
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| {
if $script_config['name'] == undef {
warning("One crontab entry for ${dbname} has no name attribute!")
next()
} elsif $script_config['script'] == undef {
warning("One crontab entry for ${dbname} has no script attribute!")
next()
} elsif $script_config['scriptparams'] == undef {
warning("One crontab entry for ${dbname} has no scriptparams attribute!")
next()
}
$log_path = "/var/log/pwb/${dbname}-${script_config['name']}-cron.log"
$command = $script_config['scriptparams'] ? {
'' => "/usr/local/bin/pywikibot ${script_config['script']} -lang:${dbname} -pt:0 >> ${log_path}"
default => "/usr/local/bin/pywikibot ${script_config['script']} ${script_config['scriptparams']} -lang:${dbname} -pt:0 >> ${log_path}"
}
# 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 >> ${log_path}",
user => 'irc',
minute => $script_config['minute'] ? {
'*' => absent,
undef => '0'
default => $script_config['minute'],
}
hour => $script_config['hour'] ? {
'*' => absent,
undef => '0'
default => $script_config['hour']
}
month => $script_config['month'] ? {
'*' => absent,
undef => '1'
default => $script_config['month']
}
monthday => $script_config['monthday'] ? {
'*' => absent,
undef => '1'
default => $script_config['monthday']
}
weekday => $script_config['weekday'] ? {
'*' => absent,
undef => '0'
default => $script_config['weekday']
}
}
# lint:ignore:selector_inside_resource
logrotate::rule { "pwb-${dbname}-${script_config['name']}-cron":
ensure => $ensure,
file_glob => $log_path,
frequency => 'daily',
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 %>')
redbluegreenhat marked this conversation as resolved.
Show resolved Hide resolved
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]

redbluegreenhat marked this conversation as resolved.
Show resolved Hide resolved
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
Loading