Dzahn has submitted this change and it was merged.

Change subject: add a script and cron to mail out bugzilla audit log and move 
bugzilla scripts to files/bugzilla instead of misc
......................................................................


add a script and cron to mail out bugzilla audit log
and move bugzilla scripts to files/bugzilla instead of misc

Change-Id: I7b49e82857b32a46e6109156ebe49078841cb5e3
---
A files/bugzilla/bugzilla_audit_log.sh
R files/bugzilla/bugzilla_community_metrics.sh
M manifests/misc/bugzilla.pp
3 files changed, 71 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Dzahn: Looks good to me, approved



diff --git a/files/bugzilla/bugzilla_audit_log.sh 
b/files/bugzilla/bugzilla_audit_log.sh
new file mode 100755
index 0000000..53f9911
--- /dev/null
+++ b/files/bugzilla/bugzilla_audit_log.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# send the Bugzilla audit log to BZ admin(s)
+# per RT-4802 - dzahn 20130328
+
+declare rcpt_address='[email protected]'
+declare sndr_address='[email protected]'
+
+# reads db user/pass/host from bugzilla config
+declare bugzilla_path='/srv/org/wikimedia/bugzilla'
+declare -a config_var=(host name user pass)
+declare -A my_var
+declare script_user='www-data'
+
+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 -s "bugzilla audit log" ${rcpt_address} -- -f 
${sndr_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/files/misc/bugzilla_community_metrics.sh 
b/files/bugzilla/bugzilla_community_metrics.sh
similarity index 100%
rename from files/misc/bugzilla_community_metrics.sh
rename to files/bugzilla/bugzilla_community_metrics.sh
diff --git a/manifests/misc/bugzilla.pp b/manifests/misc/bugzilla.pp
index cd2f30e..dc74de3 100644
--- a/manifests/misc/bugzilla.pp
+++ b/manifests/misc/bugzilla.pp
@@ -51,7 +51,7 @@
                owner => root,
                group => www-data,
                mode => 0550,
-               source => "puppet:///files/misc/bugzilla_community_metrics.sh",
+               source => 
"puppet:///files/bugzilla/bugzilla_community_metrics.sh",
                ensure => present,
        }
 
@@ -71,12 +71,32 @@
        require passwords::bugzilla
 
        file { bugzilla_report:
-               path => "/home/reporter/bugzilla_report.php",
-               owner => reporter,
-               group => reporter,
-               mode => 0550,
+               path    => '/home/reporter/bugzilla_report.php',
+               owner   => 'reporter',
+               group   => 'reporter',
+               mode    => '0550',
                content => template('misc/bugzilla_report.php'),
+               ensure  => present,
+       }
+
+}
+
+# RT-4802 - mail bz audit_log to bugzilla admins
+class misc::bugzilla::auditlog {
+
+       file { bugzilla_auditlog_file:
+               path   => '/srv/org/wikimedia/bugzilla/bugzilla_audit_log.sh',
+               owner  => 'root',
+               group  => 'www-data',
+               mode   => '0550',
+               source => 'puppet:///files/bugzilla/bugzilla_audit_log.sh',
                ensure => present,
        }
 
+       cron { bugzilla_auditlog_cron:
+               command => 'cd /srv/org/wikimedia/bugzilla/ ; 
./bugzilla_audit_log.sh',
+               user    => 'www-data',
+               hour    => 0,
+               minute  => 0,
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/56562
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7b49e82857b32a46e6109156ebe49078841cb5e3
Gerrit-PatchSet: 6
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Asher <[email protected]>
Gerrit-Reviewer: Dzahn <[email protected]>
Gerrit-Reviewer: Pyoungmeister <[email protected]>
Gerrit-Reviewer: RobLa <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to