Last modified: 2014-08-28 19:23:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T47706, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 45706 - shell wrapper to connect to databases
shell wrapper to connect to databases
Status: RESOLVED FIXED
Product: Wikimedia Labs
Classification: Unclassified
deployment-prep (beta) (Other open bugs)
unspecified
All All
: Low enhancement
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-04 16:33 UTC by Antoine "hashar" Musso (WMF)
Modified: 2014-08-28 19:23 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Antoine "hashar" Musso (WMF) 2013-03-04 16:33:52 UTC
In production, the 'sql' shell script will transparently connect a mysql client to the database of whatever project name is passed in parameter.  We need a similar wrapper in beta.

The production script relies on wikiadmin_pass which can only be run by members of the wikidev group. That in turns does not exist on beta.
Comment 1 Antoine "hashar" Musso (WMF) 2013-03-21 13:56:01 UTC
As a workaround, I use the very lame:

$ cat sql
#!/bin/sh

USER=`php -r 'include("/home/wikipedia/common/wmf-config/PrivateSettings.php"); print $wgDBuser;'`
PASS=`php -r 'include("/home/wikipedia/common/wmf-config/PrivateSettings.php"); print $wgDBpassword;'`
HOST="deployment-sql"

mysql -u $USER -p$PASS -h $HOST

$
Comment 2 Antoine "hashar" Musso (WMF) 2013-03-26 12:33:27 UTC
We should use the production sql script.  It does not work right now because:
- wikiadmin_pass belongs to the wikidev group (which does not exist on beta)
- the password there is wrong, it is populated by puppet
Comment 3 Bryan Davis 2014-05-23 17:38:23 UTC
(In reply to Antoine "hashar" Musso from comment #2)
> We should use the production sql script.  It does not work right now because:
> - wikiadmin_pass belongs to the wikidev group (which does not exist on beta)

The wikidev group does now exist in eqiad labs and beta.

> - the password there is wrong, it is populated by puppet

This password is taken from the puppet variable $passwords::misc::scripts::wikiadmin_pass. Since we have a local puppet master for beta now we can override this variable with a local commit to /var/lib/git/labs/private/modules/passwords/manifests/init.pp on the deployment-salt host. If someone knows the password for the "wikiadmin" mysql account in beta I'd be happy to fix this.
Comment 4 Yuri Astrakhan 2014-06-05 21:54:37 UTC
This also works:

  mwscript sql.php --wiki=aawiki
Comment 5 Bryan Davis 2014-06-24 15:06:38 UTC
[08:47]  <    bd808>	 hoo: We are just missing a password in the private puppet repo at this point. S.pringle probably knows what it is.
[08:47]  <      hoo>	 bd808: No, we don't
[08:47]  <      hoo>	 wikiadmin_pass is correct there
[08:48]  <      hoo>	 just the user is not wikiadmin, but mw
Comment 6 Bryan Davis 2014-08-28 19:23:09 UTC
Fixed via a local commit in the puppet repo on deployment-salt:

  $ git show --pretty 52fc928
  commit 52fc92891d53267ff2ed82b917017c288cdebaa2
  Author: Bryan Davis <bd808@wikimedia.org>
  Date:   Thu Aug 28 19:01:51 2014 +0000

      [LOCAL HACK] Change MySQL admin user in sql script

      For whatever reason the admin database user in beta has a different name than
      in production. Hack puppet to make this change.

      Bug: 45706
  
  diff --git a/files/misc/scripts/sql b/files/misc/scripts/sql
  index 2f1cddf..e5c62d1 100755
  --- a/files/misc/scripts/sql
  +++ b/files/misc/scripts/sql
  @@ -26,7 +26,7 @@ fi
   host=`echo 'echo wfGetLB()->getServerName(0);' | /usr/local/bin/mwscript eval.php --wiki="$lookupdb"`
  
   # MySQL user credentials.
  -MU=wikiadmin
  +MU=mw
   MP=`wikiadmin_pass`
  
   # Execute mysql.


Usage:
  $ sql deploymentwiki
  (mw@deployment-db1) [deploymentwiki]>

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links