Dzahn has uploaded a new change for review. https://gerrit.wikimedia.org/r/220495
Change subject: Bugzilla: remove module, keep static version ...................................................................... Bugzilla: remove module, keep static version Bug:T103193 Change-Id: Ie462d2fcb20f50cad81a4c81c0a8623a3141fed5 --- D manifests/role/bugzilla.pp A manifests/role/bugzilla_static.pp D modules/bugzilla/README.md D modules/bugzilla/manifests/apache.pp D modules/bugzilla/manifests/init.pp D modules/bugzilla/manifests/logmail.pp D modules/bugzilla/manifests/reporter.pp D modules/bugzilla/templates/apache/bugzilla.wikimedia.org.erb D modules/bugzilla/templates/localconfig.erb D modules/bugzilla/templates/scripts/bugzilla_audit_log.sh.erb D modules/bugzilla/templates/scripts/bugzilla_community_metrics.sh.erb D modules/bugzilla/templates/scripts/bugzilla_report.php.erb A modules/bugzilla_static/README.md R modules/bugzilla_static/files/static-bz-index.html R modules/bugzilla_static/manifests/init.pp R modules/bugzilla_static/templates/apache/static-bugzilla.wikimedia.org.erb 16 files changed, 23 insertions(+), 1,090 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/95/220495/1 diff --git a/manifests/role/bugzilla.pp b/manifests/role/bugzilla.pp deleted file mode 100644 index b9e8909..0000000 --- a/manifests/role/bugzilla.pp +++ /dev/null @@ -1,20 +0,0 @@ -# manifests/role/bugzilla.pp -# role for a Bugzilla server -class role::bugzilla { - - system::role { 'role::bugzilla': description => 'Bugzilla server' } - - class { '::bugzilla': - db_host => 'm1-master.eqiad.wmnet', - db_name => 'bugzilla', - db_user => 'bugs', - } - - ferm::service { 'bugzilla_http': - proto => 'tcp', - port => '80', - } - - include ::bugzilla::static -} - diff --git a/manifests/role/bugzilla_static.pp b/manifests/role/bugzilla_static.pp new file mode 100644 index 0000000..b146158 --- /dev/null +++ b/manifests/role/bugzilla_static.pp @@ -0,0 +1,14 @@ +# manifests/role/bugzilla.pp +# role for a Bugzilla server +class role::bugzilla_static { + + system::role { 'role::bugzilla_static': description => 'Static HTML Bugzilla server' } + + ferm::service { 'bugzilla_static_http': + proto => 'tcp', + port => '80', + } + + include ::bugzilla_static +} + diff --git a/modules/bugzilla/README.md b/modules/bugzilla/README.md deleted file mode 100644 index d16d835..0000000 --- a/modules/bugzilla/README.md +++ /dev/null @@ -1,27 +0,0 @@ -Bugzilla module for Wikimedia - -this module sets up parts of a custom -Bugzilla installation for Wikimedia - -production: https://bugzilla.wikimedia.org -labs/testing: https://wikitech.wikimedia.org/wiki/Nova Resource:Bugzilla -docs: http://wikitech.wikimedia.org/view/Bugzilla - -requirements: a basic Apache setup on the node - class {'webserver::php5': ssl => true; } - -this sets up: - -- the apache site config -- the SSL certs -- the /srv/org/wikimedia dir -- cronjobs and scripts: - - auditlomail for bz admins, bash - - mail report for community metrics, bash - - whine / collectstats statistics, perl - - bugzilla reporter, php - -you still have to copy upstream bugzilla itself -to the bugzilla path and clone our modifications -from the wikimedia/bugzilla/modifcations repo - diff --git a/modules/bugzilla/manifests/apache.pp b/modules/bugzilla/manifests/apache.pp deleted file mode 100644 index 84d7c49..0000000 --- a/modules/bugzilla/manifests/apache.pp +++ /dev/null @@ -1,16 +0,0 @@ -# this class sets up the Apache site config and SSL certs -# for a Wikimedia Bugzilla installation -# it expects {'webserver::php5': ssl => true; } on the node -class bugzilla::apache ($svc_name, $attach_svc_name, $docroot){ - - include ::apache::mod::headers - include ::apache::mod::expires - include ::apache::mod::env - include ::apache::mod::rewrite - - apache::site { 'bugzilla.wikimedia.org': - content => template("bugzilla/apache/bugzilla.wikimedia.org.erb"), - priority => 10, - } - -} diff --git a/modules/bugzilla/manifests/init.pp b/modules/bugzilla/manifests/init.pp deleted file mode 100644 index 6fb7053..0000000 --- a/modules/bugzilla/manifests/init.pp +++ /dev/null @@ -1,150 +0,0 @@ -# Bugzilla module for Wikimedia -# -# this module sets up parts of a custom -# Bugzilla installation for Wikimedia -# -# production: https://bugzilla.wikimedia.org -# labs/testing: https://wikitech.wikimedia.org/wiki/Nova Resource:Bugzilla -# docs: http://wikitech.wikimedia.org/view/Bugzilla -# -# requirements: a basic Apache setup on the node -# class {'webserver::php5': ssl => true; } -# -# this sets up: -# -# - the apache site config -# - the SSL certs -# - the /srv/org/wikimedia dir -# - the bugzilla localconfig file -# - cronjobs and scripts: -# - auditlog mail for bz admins, bash -# - mail report for community metrics, bash -# - whine / collectstats statistics, perl -# - bugzilla reporter, php -# -# you still have to copy upstream bugzilla itself -# to the bugzilla path and clone our modifications -# from the wikimedia/bugzilla/modifcations repo -# -class bugzilla ( $db_host, $db_name, $db_user ) { - - # document root - file { [ '/srv/org','/srv/org/wikimedia','/srv/org/wikimedia/bugzilla']: - ensure => directory, - owner => 'root', - group => 'root', - mode => '0755'; - } - - # db pass and site secret from private repo - include passwords::bugzilla - - # bugzilla localconfig - file { '/srv/org/wikimedia/bugzilla/localconfig': - ensure => present, - owner => 'root', - group => 'www-data', - mode => '0440', - content => template('bugzilla/localconfig.erb'), - } - - # basic apache site and certs - class {'bugzilla::apache': - svc_name => 'old-bugzilla.wikimedia.org', - attach_svc_name => 'bug-attachment.wikimedia.org', - docroot => '/srv/org/wikimedia/bugzilla/', - } - - # Perl modules needed by Bugzilla - # mostly per https://wiki.mozilla.org/Bugzilla:Prerequisites#Ubuntu - package { [ - 'libdatetime-perl', # manipulating dates, times and timestamps - 'libappconfig-perl', # configuration file and command line handling - 'libdate-calc-perl', # provides a variety of date calculations - 'libtemplate-perl', # template processing system - 'libmime-tools-perl', # MIME-compliant messages (formerly libmime-perl) - 'liburi-perl', # manipulate and access URI strings - 'libdatetime-timezone-perl', # framework exposing the Olson time zone database - 'libemail-send-perl', # deprecated, but we can't use libemail-sender-perl just yet - 'libemail-messageid-perl', # unique mail Message-ID generation - 'libemail-mime-perl', # for easily handling MIME-encoded messages - 'libmime-types-perl', # determining MIME types and Transfer Encoding - 'libdbi-perl', # Perl Database Interface (DBI) - 'libdbd-mysql-perl', # Perl5 database interface to the MySQL database - 'libcgi-pm-perl', # module for CGI applications (creating/parsing web forms) - 'libmath-random-isaac-perl', # Perl interface to the ISAAC PRNG algorithm - 'libmath-random-isaac-xs-perl', # ISAAC PRNG (C/XS Accelerated) (faster) - 'libxml-twig-perl', # processing huge XML documents - 'libgd-graph-perl', # Graph Plotting Module for Perl 5 - 'libchart-perl', # collection of chart creation modules (GD) - 'libjson-rpc-perl', # Perl implementation of JSON-RPC 1.1 protocol - 'libjson-xs-perl', # manipulating JSON-formatted data (C/XS-accelerated) - 'libtest-taint-perl', # test taintedness of data from an unsafe source - 'libsoap-lite-perl', # SOAP client and server - 'libtemplate-plugin-gd-perl', # GD plugin(s) for the Template Toolkit - 'libhtml-scrubber-perl', # scrubbing/sanitizing HTML - 'libencode-detect-perl', # detects the encoding of data - 'libtheschwartz-perl', # reliable job queue - 'libapache2-mod-perl2', # Apache2 Perl ('400% to 2000% speed increase':) - 'graphviz', # graph drawing tools - ]: ensure => present, - } - - # community metrics mail (T81784) - bugzilla::logmail {'communitymetrics': - script_name => 'bugzilla_community_metrics.sh', - rcpt_address => 'communitymetr...@wikimedia.org', - sndr_address => 'bugzilla-dae...@wikimedia.org', - monthday => '1', - } - - # audit log mail for admins (T82310) - bugzilla::logmail {'auditlog': - script_name => 'bugzilla_audit_log.sh', - rcpt_address => 'bugzilla-ad...@wikimedia.org', - sndr_address => 'bugzilla-dae...@wikimedia.org', - monthday => '*', - } - - # bugzilla reporter PHP script - class {'bugzilla::reporter': - bz_report_user => 'reporter', - } - - - # whining - http://www.bugzilla.org/docs/tip/en/html/whining.html - $bz_path = '/srv/org/wikimedia/bugzilla' - $whine = 'whine.pl' - - cron { 'bugzilla_whine': - ensure => 'absent', - command => "cd ${bz_path}; ./${whine}", - user => 'root', - minute => '15', - } - - # 2 cron jobs to generate charts data - # See https://bugzilla.wikimedia.org/29203 - $collectstats = 'collectstats.pl' - - # 1) get statistics for the day: - cron { 'bugzilla_collectstats': - ensure => 'absent', - command => "cd ${bz_path}; ./${collectstats} > /dev/null 2>&1", - user => 'root', - hour => '0', - minute => '5', - weekday => [ 1, 2, 3, 4, 5, 6 ] # Monday - Saturday - } - - # 2) on sunday, regenerates the whole statistics data - cron { 'bugzilla_collectstats_regenerate': - ensure => 'absent', - command => "cd ${bz_path}; ./${collectstats} --regenerate > /dev/null 2>&1", - user => root, - hour => 0, - minute => 5, - weekday => 0 # Sunday - } - -} diff --git a/modules/bugzilla/manifests/logmail.pp b/modules/bugzilla/manifests/logmail.pp deleted file mode 100644 index 41808ab..0000000 --- a/modules/bugzilla/manifests/logmail.pp +++ /dev/null @@ -1,50 +0,0 @@ -# define that sets up a cronjob and file to mail out -# the results of bugzilla statistic scripts -# -# currently used for admin audit log and community metrics -# but can be flexible about the script it uses -# -# required parameters: -# -# script_name - script you want to execute -# sndr_address - mail from: address -# rcpt_address - mail to: address -# -# optional parameters: -# -# bz_path - path to the bugzilla installation -# script_user - user running the script -# hour - hour the script is executed -# minute - minute the script is executed -# monthday - day of the month script is executed -# (use this to control how often you send mails) -# f.e. * = daily, 1 = monthly, ..) -define bugzilla::logmail ( - $script_name, - $sndr_address, - $rcpt_address, - $bz_path = '/srv/org/wikimedia/bugzilla', - $script_user = 'www-data', - $hour = '0', - $minute = '0', - $monthday = '*', -) { - - file { "${bz_path}/${script_name}": - ensure => present, - owner => 'root', - group => $script_user, - mode => '0550', - content => template("bugzilla/scripts/${script_name}.erb"), - } - - cron { "bugzillacron_${title}": - ensure => 'absent', - command => "${bz_path}/${script_name}", - user => $script_user, - hour => $hour, - minute => $minute, - monthday => $monthday, - } -} - diff --git a/modules/bugzilla/manifests/reporter.pp b/modules/bugzilla/manifests/reporter.pp deleted file mode 100644 index 927d0f9..0000000 --- a/modules/bugzilla/manifests/reporter.pp +++ /dev/null @@ -1,40 +0,0 @@ -# sets up a user and file for the 'bugzilla_report.php' script -# only parameter: user name that will run this (also used for group) -# requires: passwords::bugzilla for the PHP script to connect to db -class bugzilla::reporter ($bz_report_user = 'reporter') { - - group { 'bzreportergroup': - ensure => present, - name => $bz_report_user, - system => true, - } - - user { 'bzreporter': - home => "/home/${bz_report_user}", - groups => [ $bz_report_user ], - managehome => true, - system => true, - } - - require passwords::bugzilla - - file { 'bugzilla_report': - ensure => present, - path => "/home/${bz_report_user}/bugzilla_report.php", - owner => $bz_report_user, - group => $bz_report_user, - mode => '0550', - content => template('bugzilla/scripts/bugzilla_report.php.erb'), - } - - cron { 'bugzilla_reporter_cron': - ensure => 'absent', - command => "php -q /home/reporter/bugzilla_report.php | mail -s \"Bugzilla Weekly Report\" wikitec...@lists.wikimedia.org > /dev/null", - user => reporter, - hour => 3, - minute => 0, - weekday => 1, # Monday - } - -} - diff --git a/modules/bugzilla/templates/apache/bugzilla.wikimedia.org.erb b/modules/bugzilla/templates/apache/bugzilla.wikimedia.org.erb deleted file mode 100644 index f78e9e3..0000000 --- a/modules/bugzilla/templates/apache/bugzilla.wikimedia.org.erb +++ /dev/null @@ -1,129 +0,0 @@ -# Apache config for bugzilla.wikimedia.org -# ! THIS FILE IS MANAGED BY PUPPET ! -# ./modules/bugzilla/templates/apache/bugzilla.wikimedia.org.erb - -# you should already have these in ports.conf -# on Debian *:443 might be missing there but we puppetize that -# if you need them, uncomment the next 2 lines -# NameVirtualHost *:80 -# NameVirtualHost *:443 - -<VirtualHost *:80> - ServerAdmin webmas...@wikimedia.org - ServerName bugs.wikimedia.org - Redirect permanent / https://<%= @svc_name %>/ - RewriteEngine On - RewriteCond %{HTTP:X-Forwarded-Proto} !https - RewriteRule (.*) https://<%= @svc_name %>%{REQUEST_URI} [NE] -</VirtualHost> - -<VirtualHost *:80> - ServerAdmin webmas...@wikimedia.org - ServerName <%= @svc_name %> - DocumentRoot <%= @docroot %> - - <Directory /> - Options FollowSymLinks - AllowOverride None - </Directory> - - <Directory <%= @docroot %>> - BrowserMatchNoCase spider nobots - BrowserMatchNoCase bot nobots - Options Indexes FollowSymLinks MultiViews - AllowOverride None - Order allow,deny - Deny from env=nobots - allow from all - # This directive allows us to have apache2's default start page - # in /apache2-default/, but still have / go to the right place - #RedirectMatch ^/$ /apache2-default/ - - # For bugzilla - AddHandler cgi-script .cgi - Options +ExecCGI +FollowSymLinks - AllowOverride Limit FileInfo Indexes - DirectoryIndex index.cgi index.html - - # what Bugzilla generates in a .htaccess otherwise if you enable it - - # Don't allow people to retrieve non-cgi executable files or our private data - <FilesMatch (\.pm|\.pl|\.tmpl|localconfig.*)$> - deny from all - </FilesMatch> - - Options -Indexes - - <IfModule mod_expires.c> - <IfModule mod_headers.c> - <IfModule mod_env.c> - <FilesMatch (\.js|\.css)$> - ExpiresActive On - # According to RFC 2616, "1 year in the future" means "never expire". - # We change the name of the file's URL whenever its modification date - # changes, so browsers can cache any individual JS or CSS URL forever. - # However, since all JS and CSS URLs involve a ? in them (for the changing - # name) we have to explicitly set an Expires header or browsers won't - # *ever* cache them. - ExpiresDefault "now plus 1 years" - Header append Cache-Control "public" - </FilesMatch> - - # This lets Bugzilla know that we are properly sending Cache-Control - # and Expires headers for CSS and JS files. - SetEnv BZ_CACHE_CONTROL 1 - </IfModule> - </IfModule> - </IfModule> - # /from bugzilla generated .htaccess - - </Directory> - - ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ - - <Directory "/usr/lib/cgi-bin"> - AllowOverride None - Options ExecCGI -MultiViews +SymLinksIfOwnerMatch - Order allow,deny - Allow from all - </Directory> - -ErrorLog /var/log/apache2/error.log - -# Possible values include: debug, info, notice, warn, error, crit, -# alert, emerg. -LogLevel warn - -CustomLog /var/log/apache2/access.log combined -ServerSignature On - -RewriteEngine On -RewriteRule ^/(\d+)$ https://<%= @svc_name %>/show_bug.cgi?id=$1 [R] - -RewriteCond %{QUERY_STRING} ^(id=bug-writing.html)$ -RewriteRule /page\.cgi$ https://www.mediawiki.org/wiki/How_to_report_a_bug? [R=303] - -RewriteCond %{QUERY_STRING} ^(id=fields.html)$ -RewriteRule /page\.cgi$ https://www.mediawiki.org/wiki/Bugzilla/Fields? [R=303] - -RewriteCond %{HTTP:X-Forwarded-Proto} !https -RewriteRule (.*) https://old-bugzilla.wikimedia.org%{REQUEST_URI} [NE] - -</VirtualHost> - -<VirtualHost *:80> - ServerName <%= @attach_svc_name %> - DocumentRoot <%= @docroot %> - - <Directory /> - Order Allow,Deny - Deny from all - </Directory> - - ScriptAlias /attachment.cgi <%= @docroot %>attachment.cgi - <Location /attachment.cgi> - Order Allow,Deny - Allow from all - </Location> -</VirtualHost> - diff --git a/modules/bugzilla/templates/localconfig.erb b/modules/bugzilla/templates/localconfig.erb deleted file mode 100644 index 7c6e866..0000000 --- a/modules/bugzilla/templates/localconfig.erb +++ /dev/null @@ -1,116 +0,0 @@ -# If you are using Apache as your web server, Bugzilla can create .htaccess -# files for you, which will keep this file (localconfig) and other -# confidential files from being read over the web. -# -# If this is set to 1, checksetup.pl will create .htaccess files if -# they don't exist. -# -# If this is set to 0, checksetup.pl will not create .htaccess files. -$create_htaccess = 1; - -# The name of the group that your web server runs as. On Red Hat -# distributions, this is usually "apache". On Debian/Ubuntu, it is -# usually "www-data". -# -# If you have use_suexec turned on below, then this is instead the name -# of the group that your web server switches to to run cgi files. -# -# If this is a Windows machine, ignore this setting, as it does nothing. -# -# If you do not have access to the group your scripts will run under, -# set this to "". If you do set this to "", then your Bugzilla installation -# will be _VERY_ insecure, because some files will be world readable/writable, -# and so anyone who can get local access to your machine can do whatever they -# want. You should only have this set to "" if this is a testing installation -# and you cannot set this up any other way. YOU HAVE BEEN WARNED! -# -# If you set this to anything other than "", you will need to run checksetup.pl -# as root or as a user who is a member of the specified group. -$webservergroup = 'www-data'; - -# Set this to 1 if Bugzilla runs in an Apache SuexecUserGroup environment. -# -# If your web server runs control panel software (cPanel, Plesk or similar), -# or if your Bugzilla is to run in a shared hosting environment, then you are -# almost certainly in an Apache SuexecUserGroup environment. -# -# If this is a Windows box, ignore this setting, as it does nothing. -# -# If set to 0, checksetup.pl will set file permissions appropriately for -# a normal webserver environment. -# -# If set to 1, checksetup.pl will set file permissions so that Bugzilla -# works in a SuexecUserGroup environment. -$use_suexec = 0; - -# What SQL database to use. Default is mysql. List of supported databases -# can be obtained by listing Bugzilla/DB directory - every module corresponds -# to one supported database and the name of the module (before ".pm") -# corresponds to a valid value for this variable. -$db_driver = 'mysql'; - -# The DNS name or IP address of the host that the database server runs on. -$db_host = '<%= @db_host %>'; - -# The name of the database. For Oracle, this is the database's SID. For -# SQLite, this is a name (or path) for the DB file. -$db_name = '<%= @db_name %>'; - -# Who we connect to the database as. -$db_user = '<%= @db_user %>'; - -# Enter your database password here. It's normally advisable to specify -# a password for your bugzilla database user. -# If you use apostrophe (') or a backslash (\) in your password, you'll -# need to escape it by preceding it with a '\' character. (\') or (\) -# (It is far simpler to just not use those characters.) -$db_pass = '<%= scope.lookupvar('passwords::bugzilla::bugzilla_db_pass') %>'; - -# Sometimes the database server is running on a non-standard port. If that's -# the case for your database server, set this to the port number that your -# database server is running on. Setting this to 0 means "use the default -# port for my database server." -$db_port = 3306; - -# MySQL Only: Enter a path to the unix socket for MySQL. If this is -# blank, then MySQL's compiled-in default will be used. You probably -# want that. -$db_sock = ''; - -# Should checksetup.pl try to verify that your database setup is correct? -# With some combinations of database servers/Perl modules/moonphase this -# doesn't work, and so you can try setting this to 0 to make checksetup.pl -# run. -$db_check = 0; - -# Most web servers will allow you to use index.cgi as a directory -# index, and many come preconfigured that way, but if yours doesn't -# then you'll need an index.html file that provides redirection -# to index.cgi. Setting $index_html to 1 below will allow -# checksetup.pl to create an index.html for you if it doesn't exist. -# NOTE: checksetup.pl will not replace an existing file, so if you -# wish to have checksetup.pl create one for you, you must -# make sure that index.html doesn't already exist. -$index_html = 0; - -# If you want to use the CVS integration of the Patch Viewer, please specify -# the full path to the "cvs" executable here. -$cvsbin = '/usr/bin/cvs'; - -# If you want to use the "Difference Between Two Patches" feature of the -# Patch Viewer, please specify the full path to the "interdiff" executable -# here. -$interdiffbin = '/usr/bin/interdiff'; - -# For the "Difference Between Two Patches" feature to work, we need to know -# what directory the "diff" bin is in. (You only need to set this if you -# are using that feature of the Patch Viewer.) -$diffpath = '/usr/bin'; - -# This secret key is used by your installation for the creation and -# validation of encrypted tokens. These tokens are used to implement -# security features in Bugzilla, to protect against certain types of attacks. -# A random string is generated by default. It's very important that this key -# is kept secret. It also must be very long. -$site_wide_secret = '<%= scope.lookupvar('passwords::bugzilla::bugzilla_site_secret') %>'; - diff --git a/modules/bugzilla/templates/scripts/bugzilla_audit_log.sh.erb b/modules/bugzilla/templates/scripts/bugzilla_audit_log.sh.erb deleted file mode 100755 index 0f419a0..0000000 --- a/modules/bugzilla/templates/scripts/bugzilla_audit_log.sh.erb +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# send the Bugzilla audit log to BZ admin(s) -# per RT-4802 - dzahn 20130328 -# ! this file is managed by puppet ! -# ./modules/bugzilla/templates/scripts/<%= @script_name %>.erb - -declare rcpt_address='<%= @rcpt_address %>' -declare sndr_address='<%= @sndr_address %>' - -# reads db user/pass/host from bugzilla config -declare bugzilla_path='<%= @bz_path %>' -declare -a config_var=(host name user pass) -declare -A my_var -declare script_user='<%= @script_user %>' - -define(){ IFS='\n' read -r -d '' ${1} || true; } - -for mv in "${config_var[@]}"; do - my_var[$mv]=$(grep db_${mv} ${bugzilla_path}/localconfig | cut -d\' -f2 | sed 's/;/\\\;/g') -done - -# fix if there is a ; in the pass itself -mypass=$(echo ${my_var[pass]} | sed 's/\\//g') - -# fetch audit log from mysql db -my_result=$(/usr/bin/mysql -h ${my_var[host]} -u${my_var[user]} ${my_var[name]} -p${mypass}<< END - -select * from audit_log order by at_time desc; - -END -) - -# send it out per mail -cat <<EOF | /usr/bin/mail -r "${sndr_address}" -s "bugzilla audit log" ${rcpt_address} - -Hi Bugzilla admins, - -this is your automatic Bugzilla audit log mail: - -$my_result - -Yours sincerely, - -Bugs Zilla - -(via $(basename $0) on $(hostname) at $(date)) -EOF - diff --git a/modules/bugzilla/templates/scripts/bugzilla_community_metrics.sh.erb b/modules/bugzilla/templates/scripts/bugzilla_community_metrics.sh.erb deleted file mode 100755 index 7237226..0000000 --- a/modules/bugzilla/templates/scripts/bugzilla_community_metrics.sh.erb +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# send the number of active users on Bugzilla -# in the last month to "community metrics" team -# per RT-3962 - dzahn 20121219 -# ! this file is managed by puppet ! -# ./modules/bugzilla/templates/scripts/<%= @script_name %>.erb - -declare rcpt_address='<%= @rcpt_address %>' -declare sndr_address='<%= @sndr_address %>' - -# reads db user/pass/host from bugzilla config -declare bugzilla_path='<%= @bz_path %>' -declare -a config_var=(host name user pass) -declare -A my_var -declare script_user='<%= @script_user %>' - -define(){ IFS='\n' read -r -d '' ${1} || true; } - -for mv in "${config_var[@]}"; do - my_var[$mv]=$(grep db_${mv} ${bugzilla_path}/localconfig | cut -d\' -f2 | sed 's/;/\\\;/g') -done - -# fix if there is a ; in the pass itself -mypass=$(echo ${my_var[pass]} | sed 's/\\//g') - -my_result=$(MYSQL_PWD=${mypass} /usr/bin/mysql -h ${my_var[host]} -u${my_var[user]} ${my_var[name]} << END - -select - count(distinct userid) -from -( - select - ba.who as userid, - ba.bug_when as action_date - from bugs_activity ba - where - date_format(ba.bug_when,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m') and - ba.fieldid in (2,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,30,35,36,37,38,40,41,42,47,55,56,57,58) - group by action_date,userid - union all - select - b.reporter, - b.creation_ts - from bugs b - where - date_format(b.creation_ts,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m') -) as filtered_actions; - -END -) - -activeusers=$(echo $my_result | cut -d " " -f3) -lastmonth=$(date --date="last month" +%Y-%m) - -# the actual email -cat <<EOF | /usr/bin/mail -r "${sndr_address}" -s "bugzilla stats - ${lastmonth}" ${rcpt_address} - -Hi Community Metrics team, - -this is your automatic monthly Bugzilla statistics mail. - -The number of active users in Bugzilla in the last month (${lastmonth}) was: ${activeusers} - -Yours sincerely, - -Bugs Zilla - -(via $(basename $0) on $(hostname) at $(date)) -EOF - diff --git a/modules/bugzilla/templates/scripts/bugzilla_report.php.erb b/modules/bugzilla/templates/scripts/bugzilla_report.php.erb deleted file mode 100755 index 42d0bae..0000000 --- a/modules/bugzilla/templates/scripts/bugzilla_report.php.erb +++ /dev/null @@ -1,421 +0,0 @@ -#!/usr/bin/php -<?php error_reporting(E_ALL); - -function getBugsPerProduct ($begin_date,$end_date) { - print "Created reports per product\n\n"; - return <<<END -SELECT - name, count(*) as total -FROM - bugs -JOIN - products - on - product_id = products.id -WHERE - creation_ts -BETWEEN - "$begin_date" - and - "$end_date" -GROUP BY - product_id -ORDER BY - total -DESC -LIMIT 5; -END; -} - -function getBugsPerComponent ($begin_date,$end_date) { - print "Created reports per component\n\n"; - return <<<END -SELECT - products.name, components.name, count(*) as total -FROM - bugs -JOIN - components - on - bugs.component_id = components.id -JOIN - products - on - bugs.product_id = products.id -WHERE - creation_ts -BETWEEN - "$begin_date" - and - "$end_date" -GROUP BY - component_id -ORDER BY - total -DESC -LIMIT - 5; - -END; -} - -function getBugsResolvedPerUser($begin_date,$end_date) { - print "Top 5 bug report closers\n\n"; - return <<<END -SELECT - login_name, count(*) as total -FROM - bugs_activity -JOIN - profiles - on - who = profiles.userid -WHERE - added = 'RESOLVED' - and - bug_when -BETWEEN - "$begin_date" - and - "$end_date" -GROUP BY - who -ORDER BY - total -DESC -LIMIT - 5; -END; -} -function getBugResolutions($begin_date, $end_date, $resolution) { - $resolution = mysql_real_escape_string($resolution); - $resolution = "'$resolution'"; - - return <<<END -SELECT - count(distinct bugs.bug_id) -FROM - bugs, bugs_activity -WHERE - bugs.resolution = $resolution -AND - bugs_activity.added = $resolution -AND - bugs_activity.bug_when -BETWEEN - "$begin_date" -AND - "$end_date" -AND - bugs.bug_id = bugs_activity.bug_id; -END; -} - -function getBugsChangingStatus($begin_date, $end_date, $state) { - $state = mysql_real_escape_string($state); - $state = "'$state'"; - - return <<<END -SELECT - count(*) -FROM - bugs, bugs_activity -WHERE - bugs.bug_status = $state -AND - bugs_activity.added = $state -AND - bugs_activity.bug_when -BETWEEN - "$begin_date" - and - "$end_date" -AND - bugs.bug_id = bugs_activity.bug_id; -END; -} - -function getTotalOpenReports() { - return <<<END -SELECT - count(*) -FROM - bugs -WHERE - bug_status = 'UNCONFIRMED' or - bug_status = 'ASSIGNED' or - bug_status = 'NEW' or - bug_status = 'PATCH_TO_REVIEW' or - bug_status = 'REOPENED'; -END; -} - -function getTotalOpenEnhancements() { - return <<<END -SELECT - count(*) -FROM - bugs -WHERE - (bug_status = 'UNCONFIRMED' or - bug_status = 'ASSIGNED' or - bug_status = 'NEW' or - bug_status = 'PATCH_TO_REVIEW' or - bug_status = 'REOPENED') -AND - bug_severity = 'enhancement'; -END; -} - -function getTotalOpenBugs() { - return <<<END -SELECT - count(*) -FROM - bugs -WHERE - (bug_status = 'UNCONFIRMED' or - bug_status = 'ASSIGNED' or - bug_status = 'NEW' or - bug_status = 'PATCH_TO_REVIEW' or - bug_status = 'REOPENED') -AND - bug_severity != 'enhancement'; -END; -} - -function getTotalOpenBugsNonLowestPriority() { - return <<<END -SELECT - count(*) -FROM - bugs -WHERE - (bug_status = 'UNCONFIRMED' or - bug_status = 'ASSIGNED' or - bug_status = 'NEW' or - bug_status = 'PATCH_TO_REVIEW' or - bug_status = 'REOPENED') -AND - bug_severity != 'enhancement' -AND - priority != 'lowest'; -END; -} - -function getBugsCreated($begin_date, $end_date) { - return <<<END -SELECT - count(bug_id) -FROM - bugs -WHERE - creation_ts -BETWEEN - "$begin_date" - and - "$end_date" -END; -} - -function getHighestPrioTickets() { - return <<<END -SELECT - products.name AS product, - components.name AS component, - bugs.bug_id AS bugID, - bugs.priority, - bugs.delta_ts, - profiles.login_name AS assignee, - bugs.short_desc as bugsummary -FROM - bugs -JOIN - profiles ON assigned_to = profiles.userid -JOIN - products ON bugs.product_id = products.id -JOIN - components ON bugs.component_id = components.id -LEFT JOIN - bug_group_map AS security_map ON bugs.bug_id = security_map.bug_id -WHERE - ( security_map.group_id != 15 OR security_map.group_id IS NULL ) -AND - ( bug_status != "RESOLVED" AND bug_status != "VERIFIED" AND bug_status != "CLOSED" ) -AND - ( priority = "Highest" OR priority = "Immediate" ) -ORDER BY - product, component, delta_ts -LIMIT - 200; -END; -} - -function formatOutput($result) { - while ($row = mysql_fetch_row($result)) { - if (is_array($row)) { - foreach ($row as $row_i) { - $row_i = str_replace ( '@', ' [AT] ', $row_i); //strip out any easy scrapes - print pack('A30',($row_i)); - } - } - else { - print "0\n"; - } - print "\n"; - } -} - -function reportFailure($text) { - print "Wikimedia Bugzilla report (FAILED), $text "; - die( "FAILED\n\n$text\n" ); -} - -function formatOutputHighestPrio($result) { - printf( "%-13.13s | %-13.13s | %5s | %-9.9s | %-10.10s | %-20.20s | %-37.37s\n", - "Product", "Component", "BugID", "Priority", "LastChange", "Assignee", "Summary" ); - printf ( "%-60s", "--------------------------------------------------------------" ); - print "\n"; - while ($row = mysql_fetch_row($result)) { - foreach ($row as $row_i) { - $row = str_replace ( '@', '[AT]', $row); - } - printf( "%-13.13s | %-13.13s | %5s | %-9.9s | %-10.10s | %-20.20s | %-37.37s", - $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6] ); - print "\n\n"; - } -} - -# main - -$options = getopt('b:e:'); - -if ( !isset($options['e'])) - $end_date = strtotime('now'); -else - $end_date = strtotime($options['e']); -if ( !isset($options['b']) ) { - $begin_date = $end_date - 86400*7 ; -} -else - $begin_date = strtotime($options['b']); - -print "MediaWiki Bugzilla Report for " . date('F d, Y', $begin_date) . " - " . date('F d, Y', $end_date) . "\n\n"; -/* TODO: mysql_connect is deprecated - switch to MySQLi or PDO */ -$ok = mysql_connect("<%= scope.lookupvar('bugzilla::db_host') %>", "bugs", "<%= scope.lookupvar('passwords::bugzilla::bugzilla_db_pass') %>"); -if (!$ok) - reportFailure("DB connection failure"); - -$ok = mysql_select_db("<%= scope.lookupvar('bugzilla::db_name') %>"); -if (!$ok) - reportFailure("DB selection failure"); - -$reportsPerItem = array ('getBugsPerComponent', - 'getBugsPerProduct', - 'getBugsResolvedPerUser',); - -$statesToRun = array('UNCONFIRMED', - 'NEW', - 'ASSIGNED', - 'REOPENED', - 'PATCH_TO_REVIEW', - 'RESOLVED', - 'VERIFIED',); - -$resolutionsToRun = array('FIXED', 'DUPLICATE', - 'INVALID', 'WORKSFORME', - 'WONTFIX',); - -$totalStatistics = array ('getTotalOpenReports',); - -$totalStatisticsEnhancements = array ('getTotalOpenEnhancements',); - -$totalStatisticsBugs = array ('getTotalOpenBugs',); - -$totalStatisticsBugsNonLowestPriority = array ('getTotalOpenBugsNonLowestPriority',); - -$createdStatistics = array('getBugsCreated',); - -$urgentStatistics = array('getHighestPrioTickets',); - -print "Status changes this week\n\n"; -foreach ($statesToRun as $state) { - $sql = getBugsChangingStatus(date('Y-m-d',$begin_date),date('Y-m-d',$end_date), $state); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - print pack('A34A3',"Reports changed/set to $state",":"); - formatOutput($result); -} - -foreach ($totalStatistics as $report) { - $sql = getTotalOpenReports(); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - print "\nTotal reports still open : "; - formatOutput($result); -} - -foreach ($totalStatisticsBugs as $report) { - $sql = getTotalOpenBugs(); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - print "Total bugs still open : "; - formatOutput($result); -} - -foreach ($totalStatisticsBugsNonLowestPriority as $report) { - $sql = getTotalOpenBugsNonLowestPriority(); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - print "Total non-lowest prio. bugs still open: "; - formatOutput($result); -} - -foreach ($totalStatisticsEnhancements as $report) { - $sql = getTotalOpenEnhancements(); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - print "Total enhancements still open : "; - formatOutput($result); -} - -foreach ($createdStatistics as $report) { - $sql = getBugsCreated(date('Y-m-d', $begin_date),date('Y-m-d', $end_date)); - $result = mysql_query($sql); - if (!$result) - reportFailure( 'Query failure' ); - print "\nReports created this week: "; - formatOutput( $result ); -} - -print "\nResolutions for the week:\n\n"; -foreach ($resolutionsToRun as $resolution) { - $sql = getBugResolutions(date('Y-m-d',$begin_date),date('Y-m-d',$end_date), $resolution); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - print pack('A25A3',"Reports marked $resolution",":"); - formatOutput($result); -} -print "\nSpecific Product/Component Resolutions & User Metrics \n\n"; -foreach ($reportsPerItem as $report) { - $sql = $report(date('Y-m-d',$begin_date),date('Y-m-d',$end_date)); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - formatOutput($result); - print "\n"; -} -print "\nMost urgent open issues\n\n"; -foreach ($urgentStatistics as $report) { - $sql = getHighestPrioTickets(); - $result = mysql_query($sql); - if (!$result) - reportFailure("Query failure"); - formatOutputHighestPrio($result); -} diff --git a/modules/bugzilla_static/README.md b/modules/bugzilla_static/README.md new file mode 100644 index 0000000..a0c0040 --- /dev/null +++ b/modules/bugzilla_static/README.md @@ -0,0 +1,6 @@ +This module sets up a static HTML version of +the former Wikimedia Bugzilla installation. + +requirements: a basic Apache setup on the node + class {'webserver::php5': ssl => true; } + diff --git a/modules/bugzilla/files/static-bz-index.html b/modules/bugzilla_static/files/static-bz-index.html similarity index 100% rename from modules/bugzilla/files/static-bz-index.html rename to modules/bugzilla_static/files/static-bz-index.html diff --git a/modules/bugzilla/manifests/static.pp b/modules/bugzilla_static/manifests/init.pp similarity index 74% rename from modules/bugzilla/manifests/static.pp rename to modules/bugzilla_static/manifests/init.pp index 6c3d872..d3a0c2c 100644 --- a/modules/bugzilla/manifests/static.pp +++ b/modules/bugzilla_static/manifests/init.pp @@ -1,6 +1,6 @@ # sets up a static HTML version of the old Bugzilla install # T85140 -class bugzilla::static { +class bugzilla_static { file { '/srv/org/wikimedia/static-bugzilla': ensure => directory, @@ -14,14 +14,14 @@ owner => 'www-data', group => 'www-data', mode => '0400', - source => 'puppet:///modules/bugzilla/static-bz-index.html'; + source => 'puppet:///modules/bugzilla_static/static-bz-index.html'; } include ::apache::mod::rewrite include ::apache::mod::headers apache::site { 'static-bugzilla.wikimedia.org': - content => template('bugzilla/apache/static-bugzilla.wikimedia.org.erb'), + content => template('bugzilla_static/apache/static-bugzilla.wikimedia.org.erb'), priority => 20, } diff --git a/modules/bugzilla/templates/apache/static-bugzilla.wikimedia.org.erb b/modules/bugzilla_static/templates/apache/static-bugzilla.wikimedia.org.erb similarity index 100% rename from modules/bugzilla/templates/apache/static-bugzilla.wikimedia.org.erb rename to modules/bugzilla_static/templates/apache/static-bugzilla.wikimedia.org.erb -- To view, visit https://gerrit.wikimedia.org/r/220495 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie462d2fcb20f50cad81a4c81c0a8623a3141fed5 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Dzahn <dz...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits